Skip to content

Commit 0e79bcf

Browse files
committed
reveal tracked position
1 parent adce811 commit 0e79bcf

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

src/features/trackPositions.ts

+19-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ export default () => {
2222
historyPerEditor.set(key, history)
2323
}
2424

25+
let writePositions = true
26+
2527
const pushPosition = (kind?: OurKind, forceAdd = false) => {
28+
if (!writePositions) return
2629
const editor = vscode.window.activeTextEditor
2730
if (!editor) return
2831
const position = editor.selection.active
@@ -93,6 +96,7 @@ export default () => {
9396
}),
9497
)
9598

99+
const currentPos = editor.selection.active
96100
const index = await showQuickPick(getItems(), {
97101
title: 'Tracked Positions Stack',
98102
ignoreFocusOut: true,
@@ -101,13 +105,24 @@ export default () => {
101105
this.items = getItems()
102106
}
103107
},
108+
onDidChangeFirstActive(item, index) {
109+
writePositions = false
110+
const [selectedPos] = history[index]!
111+
editor.selection = new vscode.Selection(selectedPos, selectedPos)
112+
editor.revealRange(new vscode.Range(selectedPos, selectedPos))
113+
setTimeout(() => {
114+
writePositions = true
115+
})
116+
},
104117
})
105118
onHistoryUpdate = undefined
106-
if (index === undefined) return
119+
if (index === undefined) {
120+
editor.selection = new vscode.Selection(currentPos, currentPos)
121+
editor.revealRange(new vscode.Range(currentPos, currentPos))
122+
return
123+
}
124+
107125
void vscode.window.showTextDocument(uri)
108-
const [selectedPos] = history[index]!
109-
editor.selection = new vscode.Selection(selectedPos, selectedPos)
110-
editor.revealRange(new vscode.Range(selectedPos, selectedPos))
111126
})
112127
disposables.push(extensionCtx.subscriptions.at(-1)!)
113128
registerExtensionCommand('goToPreviousTrackedPosition', () => {

0 commit comments

Comments
 (0)