Skip to content

Commit

Permalink
Fix #141051
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackson Kearl committed Mar 3, 2022
1 parent 95ba1e1 commit 9ca5c88
Showing 1 changed file with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 9ca5c88

Please sign in to comment.