diff --git a/src/vs/workbench/services/configurationResolver/browser/configurationResolverService.ts b/src/vs/workbench/services/configurationResolver/browser/configurationResolverService.ts index 473e7f2eca868..194e7a93d36e1 100644 --- a/src/vs/workbench/services/configurationResolver/browser/configurationResolverService.ts +++ b/src/vs/workbench/services/configurationResolver/browser/configurationResolverService.ts @@ -14,13 +14,12 @@ import { ICommandService } from 'vs/platform/commands/common/commands'; import { IWorkspaceFolder, IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { AbstractVariableResolverService } from 'vs/workbench/services/configurationResolver/common/variableResolver'; -import { isCodeEditor, isDiffEditor } from 'vs/editor/browser/editorBrowser'; +import { ICodeEditor, isCodeEditor, isDiffEditor } from 'vs/editor/browser/editorBrowser'; import { IQuickInputService, IInputOptions, IQuickPickItem, IPickOptions } from 'vs/platform/quickinput/common/quickInput'; import { ConfiguredInput } from 'vs/workbench/services/configurationResolver/common/configurationResolver'; import { IProcessEnvironment } from 'vs/base/common/platform'; import { ILabelService } from 'vs/platform/label/common/label'; import { IPathService } from 'vs/workbench/services/path/common/pathService'; -import { ITextModel } from 'vs/editor/common/model'; export abstract class BaseConfigurationResolverService extends AbstractVariableResolverService { @@ -84,19 +83,18 @@ export abstract class BaseConfigurationResolverService extends AbstractVariableR getSelectedText: (): string | undefined => { const activeTextEditorControl = editorService.activeTextEditorControl; - let activeModel: ITextModel | null = null; + let activeControl: ICodeEditor | null = null; + if (isCodeEditor(activeTextEditorControl)) { - activeModel = activeTextEditorControl.getModel(); - } - if (isDiffEditor(activeTextEditorControl)) { - if (activeTextEditorControl.getOriginalEditor().hasTextFocus()) { - activeModel = activeTextEditorControl.getOriginalEditor().getModel(); - } else { - activeModel = activeTextEditorControl.getModifiedEditor().getModel(); - } + activeControl = activeTextEditorControl; + } else if (isDiffEditor(activeTextEditorControl)) { + const original = activeTextEditorControl.getOriginalEditor(); + const modified = activeTextEditorControl.getModifiedEditor(); + activeControl = original.hasWidgetFocus() ? original : modified; } - const activeSelection = activeTextEditorControl?.getSelection(); + const activeModel = activeControl?.getModel(); + const activeSelection = activeControl?.getSelection(); if (activeModel && activeSelection) { return activeModel.getValueInRange(activeSelection); }