From 802cf0c136fa30d5a4e69b6cee60e20fb650636d Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Fri, 20 Oct 2023 14:00:28 -0700 Subject: [PATCH] Reveal selection after editing deactivate script (#22271) --- .../envCollectionActivation/deactivatePrompt.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/client/terminals/envCollectionActivation/deactivatePrompt.ts b/src/client/terminals/envCollectionActivation/deactivatePrompt.ts index 43d1e77957bc..c1a7e3d08f49 100644 --- a/src/client/terminals/envCollectionActivation/deactivatePrompt.ts +++ b/src/client/terminals/envCollectionActivation/deactivatePrompt.ts @@ -2,7 +2,16 @@ // Licensed under the MIT License. import { inject, injectable } from 'inversify'; -import { Position, Uri, WorkspaceEdit, Range, TextEditorRevealType, ProgressLocation, Terminal } from 'vscode'; +import { + Position, + Uri, + WorkspaceEdit, + Range, + TextEditorRevealType, + ProgressLocation, + Terminal, + Selection, +} from 'vscode'; import { IApplicationEnvironment, IApplicationShell, @@ -141,12 +150,17 @@ ${content} // If script already has the hook, don't add it again. const editor = await this.documentManager.showTextDocument(document); if (document.getText().includes(hookMarker)) { + editor.revealRange( + new Range(new Position(document.lineCount - 3, 0), new Position(document.lineCount, 0)), + TextEditorRevealType.AtTop, + ); return; } const editorEdit = new WorkspaceEdit(); editorEdit.insert(document.uri, new Position(document.lineCount, 0), content); await this.documentManager.applyEdit(editorEdit); // Reveal the edits. + editor.selection = new Selection(new Position(document.lineCount - 3, 0), new Position(document.lineCount, 0)); editor.revealRange( new Range(new Position(document.lineCount - 3, 0), new Position(document.lineCount, 0)), TextEditorRevealType.AtTop,