提交 ebf16df6 编写于 作者: E Eric Gang

Fix a compiler error

I didn't notice the preservation should be put under a condition
上级 dd1cbbec
......@@ -230,10 +230,7 @@ export class CommandCenter {
}
if (!left) {
const previousVisibleRanges = activeTextEditor.visibleRanges;
const document = await workspace.openTextDocument(right);
const editor = await window.showTextDocument(document, opts);
editor.revealRange(previousVisibleRanges[0]);
await commands.executeCommand<void>('vscode.open', right, opts);
} else {
await commands.executeCommand<void>('vscode.diff', left, right, title, opts);
}
......@@ -574,16 +571,19 @@ export class CommandCenter {
viewColumn: ViewColumn.Active
};
const document = await workspace.openTextDocument(uri);
// Check if active text editor has same path as other editor. we cannot compare via
// URI.toString() here because the schemas can be different. Instead we just go by path.
if (activeTextEditor && activeTextEditor.document.uri.path === uri.path) {
// preserve not only selection but also visible range
opts.selection = activeTextEditor.selection;
}
const previousVisibleRanges = activeTextEditor.visibleRanges;
const document = await workspace.openTextDocument(uri);
const editor = await window.showTextDocument(document, opts);
editor.revealRange(previousVisibleRanges[0]);
} else {
await window.showTextDocument(document, opts);
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册