diff options
author | Nate Sesti <33237525+sestinj@users.noreply.github.com> | 2023-06-27 11:43:24 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-27 11:43:24 -0700 |
commit | a32d1b7766844bccc8b0a8dff4a290654446abe9 (patch) | |
tree | c47db0ce7cf8be5524103eb62e8f3843ef5b3d99 /extension/src/continueIdeClient.ts | |
parent | 3a39f7029f7faf5c77d4678ce6d796e4c99b558b (diff) | |
parent | bf998a752a547485189f5ac1dc415d7ec475099e (diff) | |
download | sncontinue-a32d1b7766844bccc8b0a8dff4a290654446abe9.tar.gz sncontinue-a32d1b7766844bccc8b0a8dff4a290654446abe9.tar.bz2 sncontinue-a32d1b7766844bccc8b0a8dff4a290654446abe9.zip |
Merge pull request #155 from continuedev/newer-simpler-stream-algo
Newer simpler stream algo
Diffstat (limited to 'extension/src/continueIdeClient.ts')
-rw-r--r-- | extension/src/continueIdeClient.ts | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/extension/src/continueIdeClient.ts b/extension/src/continueIdeClient.ts index 08a0b74d..8ab3e075 100644 --- a/extension/src/continueIdeClient.ts +++ b/extension/src/continueIdeClient.ts @@ -1,5 +1,8 @@ // import { ShowSuggestionRequest } from "../schema/ShowSuggestionRequest"; -import { showSuggestion, SuggestionRanges } from "./suggestions"; +import { + showSuggestion as showSuggestionInEditor, + SuggestionRanges, +} from "./suggestions"; import { openEditorAndRevealRange, getRightViewColumn } from "./util/vscode"; import { FileEdit } from "../schema/FileEdit"; import { RangeInFile } from "../schema/RangeInFile"; @@ -114,7 +117,10 @@ class IdeProtocolClient { break; case "setFileOpen": this.openFile(data.filepath); - // TODO: Close file + // TODO: Close file if False + break; + case "showSuggestion": + this.showSuggestion(data.edit); break; case "openGUI": case "connected": @@ -138,6 +144,7 @@ class IdeProtocolClient { // ------------------------------------ // // On message handlers + private _lastDecorationType: vscode.TextEditorDecorationType | null = null; async highlightCode(rangeInFile: RangeInFile, color: string) { const range = new vscode.Range( rangeInFile.range.start.line, @@ -157,24 +164,25 @@ class IdeProtocolClient { }); editor.setDecorations(decorationType, [range]); - // Listen for changes to cursor position and then remove the decoration (but keep for at least 2 seconds) - const allowRemoveHighlight = () => { - const cursorDisposable = vscode.window.onDidChangeTextEditorSelection( - (event) => { - if (event.textEditor.document.uri.fsPath === rangeInFile.filepath) { - cursorDisposable.dispose(); - editor.setDecorations(decorationType, []); - } + const cursorDisposable = vscode.window.onDidChangeTextEditorSelection( + (event) => { + if (event.textEditor.document.uri.fsPath === rangeInFile.filepath) { + cursorDisposable.dispose(); + editor.setDecorations(decorationType, []); } - ); - }; - setTimeout(allowRemoveHighlight, 2000); + } + ); + + if (this._lastDecorationType) { + editor.setDecorations(this._lastDecorationType, []); + } + this._lastDecorationType = decorationType; } } showSuggestion(edit: FileEdit) { // showSuggestion already exists - showSuggestion( + showSuggestionInEditor( edit.filepath, new vscode.Range( edit.range.start.line, |