feat: add event registration methods
This commit is contained in:
parent
201e34c0eb
commit
b324391e35
3 changed files with 73 additions and 0 deletions
|
|
@ -1,6 +1,10 @@
|
|||
import { NextEditProvider } from "core/nextEdit/NextEditProvider";
|
||||
import { NextEditOutcome } from "core/nextEdit/types";
|
||||
import * as vscode from "vscode";
|
||||
import {
|
||||
HandlerPriority,
|
||||
SelectionChangeManager,
|
||||
} from "./SelectionChangeManager";
|
||||
|
||||
export interface CompletionDataForAfterJump {
|
||||
completionId: string;
|
||||
|
|
@ -347,4 +351,23 @@ export class JumpManager {
|
|||
get completionAfterJump() {
|
||||
return this._completionAfterJump;
|
||||
}
|
||||
|
||||
public registerSelectionChangeHandler(): void {
|
||||
const manager = SelectionChangeManager.getInstance();
|
||||
|
||||
manager.registerListener(
|
||||
"jumpManager",
|
||||
async (e, state) => {
|
||||
if (state.jumpInProgress || state.jumpJustAccepted) {
|
||||
console.log(
|
||||
"JumpManager: jump in progress or just accepted, preserving chain",
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
HandlerPriority.HIGH,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,10 @@ import { getOffsetPositionAtLastNewLine } from "core/nextEdit/diff/diff";
|
|||
import { NextEditLoggingService } from "core/nextEdit/NextEditLoggingService";
|
||||
import { NextEditProvider } from "core/nextEdit/NextEditProvider";
|
||||
import { getThemeString } from "../util/getTheme";
|
||||
import {
|
||||
HandlerPriority,
|
||||
SelectionChangeManager,
|
||||
} from "./SelectionChangeManager";
|
||||
|
||||
export interface TextApplier {
|
||||
applyText(
|
||||
|
|
@ -848,6 +852,24 @@ export class NextEditWindowManager {
|
|||
public hasAccepted() {
|
||||
return this.accepted;
|
||||
}
|
||||
|
||||
public registerSelectionChangeHandler(): void {
|
||||
const manager = SelectionChangeManager.getInstance();
|
||||
|
||||
manager.registerListener(
|
||||
"nextEditWindowManager",
|
||||
async (e, state) => {
|
||||
if (state.nextEditWindowAccepted) {
|
||||
console.log(
|
||||
"NextEditWindowManager: Edit was just accepted, preserving chain",
|
||||
);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
HandlerPriority.CRITICAL,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default async function setupNextEditWindowManager(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
import * as vscode from "vscode";
|
||||
import {
|
||||
HandlerPriority,
|
||||
SelectionChangeManager,
|
||||
} from "../activation/SelectionChangeManager";
|
||||
|
||||
export interface ExpectedGhostTextAcceptance {
|
||||
documentUri: string;
|
||||
|
|
@ -114,4 +118,28 @@ export class GhostTextAcceptanceTracker {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
public registerSelectionChangeHandler(): void {
|
||||
const manager = SelectionChangeManager.getInstance();
|
||||
|
||||
manager.registerListener(
|
||||
"ghostTextTracker",
|
||||
async (e, state) => {
|
||||
const wasGhostTextAccepted = this.checkGhostTextWasAccepted(
|
||||
e.textEditor.document,
|
||||
e.selections[0].active,
|
||||
);
|
||||
|
||||
if (wasGhostTextAccepted) {
|
||||
console.log(
|
||||
"GhostTextAcceptanceTracker: ghost text was accepted, preserving chain",
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
HandlerPriority.HIGH,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue