mirror of
https://github.com/Microsoft/vscode
synced 2024-10-02 17:32:41 +00:00
parent
cdb1a962cc
commit
12997e68fd
|
@ -1194,7 +1194,7 @@ export class CommandCenter {
|
|||
|
||||
const activeTextEditor = window.activeTextEditor;
|
||||
// Must extract these now because opening a new document will change the activeTextEditor reference
|
||||
const previousVisibleRange = activeTextEditor?.visibleRanges[0];
|
||||
const previousVisibleRanges = activeTextEditor?.visibleRanges;
|
||||
const previousURI = activeTextEditor?.document.uri;
|
||||
const previousSelection = activeTextEditor?.selection;
|
||||
|
||||
|
@ -1225,8 +1225,13 @@ export class CommandCenter {
|
|||
opts.selection = previousSelection;
|
||||
const editor = await window.showTextDocument(document, opts);
|
||||
// This should always be defined but just in case
|
||||
if (previousVisibleRange) {
|
||||
editor.revealRange(previousVisibleRange);
|
||||
if (previousVisibleRanges && previousVisibleRanges.length > 0) {
|
||||
let rangeToReveal = previousVisibleRanges[0];
|
||||
if (previousSelection && previousVisibleRanges.length > 1) {
|
||||
// In case of multiple visible ranges, find the one that intersects with the selection
|
||||
rangeToReveal = previousVisibleRanges.find(r => r.intersection(previousSelection)) ?? rangeToReveal;
|
||||
}
|
||||
editor.revealRange(rangeToReveal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue