Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

November debt #136207

Merged
merged 9 commits into from
Nov 1, 2021
Prev Previous commit
editors - simplify setting editor to pane more
  • Loading branch information
bpasero committed Nov 1, 2021
commit 6874b0315b921584ad61477f7238f98730f581b9
20 changes: 6 additions & 14 deletions src/vs/workbench/browser/parts/editor/editorPanes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,27 +264,19 @@ export class EditorPanes extends Disposable {
}

private async doSetInput(editorPane: EditorPane, operation: IOperation, editor: EditorInput, options: IEditorOptions | undefined, context: IEditorOpenContext): Promise<boolean> {
const forceReload = options?.forceReload;
const inputMatches = editorPane.input?.matches(editor);

// If the input did not change, return early and only apply the options
// unless the options instruct us to force open it even if it is the same
const forceReload = options?.forceReload;
const inputMatches = editorPane.input?.matches(editor);
if (inputMatches && !forceReload) {

// Forward options
editorPane.setOptions(options);

// Still focus as needed
const focus = !options || !options.preserveFocus;
if (focus) {
editorPane.focus();
}

return false;
}

// Call into editor pane
await editorPane.setInput(editor, options, context, operation.token);
// Otherwise set the input to the editor pane
else {
await editorPane.setInput(editor, options, context, operation.token);
}

return !inputMatches;
}
Expand Down