Skip to content

Commit

Permalink
Reveal selection after editing deactivate script (#22271)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Raj authored Oct 20, 2023
1 parent 6333752 commit 802cf0c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/client/terminals/envCollectionActivation/deactivatePrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 802cf0c

Please sign in to comment.