Skip to content

Commit

Permalink
Remove microsoft#128927 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ssigwart committed Oct 26, 2021
1 parent 657964d commit d94b475
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 40 deletions.
34 changes: 14 additions & 20 deletions src/vs/editor/contrib/gotoSymbol/goToCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ abstract class SymbolNavigationAction extends EditorAction {
this._configuration = configuration;
}

run(accessor: ServicesAccessor, editor: ICodeEditor, args?: any | undefined): Promise<void> {
run(accessor: ServicesAccessor, editor: ICodeEditor): Promise<void> {
if (!editor.hasModel()) {
return Promise.resolve(undefined);
}
Expand Down Expand Up @@ -116,7 +116,7 @@ abstract class SymbolNavigationAction extends EditorAction {

} else {
// normal results handling
return this._onResult(editorService, symbolNavService, editor, references, args);
return this._onResult(editorService, symbolNavService, editor, references);
}

}, (err) => {
Expand All @@ -138,7 +138,7 @@ abstract class SymbolNavigationAction extends EditorAction {

protected abstract _getGoToPreference(editor: IActiveCodeEditor): GoToLocationValues;

private async _onResult(editorService: ICodeEditorService, symbolNavService: ISymbolNavigationService, editor: IActiveCodeEditor, model: ReferencesModel, args: any): Promise<void> {
private async _onResult(editorService: ICodeEditorService, symbolNavService: ISymbolNavigationService, editor: IActiveCodeEditor, model: ReferencesModel): Promise<void> {

const gotoLocation = this._getGoToPreference(editor);
if (!(editor instanceof EmbeddedCodeEditorWidget) && (this._configuration.openInPeek || (gotoLocation === 'peek' && model.references.length > 1))) {
Expand All @@ -147,7 +147,7 @@ abstract class SymbolNavigationAction extends EditorAction {
} else {
const next = model.firstReference()!;
const peek = model.references.length > 1 && gotoLocation === 'gotoAndPeek';
const targetEditor = await this._openReference(editor, editorService, next, this._configuration.openToSide, !peek, args.selectionRange);
const targetEditor = await this._openReference(editor, editorService, next, this._configuration.openToSide, !peek);
if (peek && targetEditor) {
this._openInPeek(targetEditor, model);
} else {
Expand All @@ -162,30 +162,24 @@ abstract class SymbolNavigationAction extends EditorAction {
}
}

private async _openReference(editor: ICodeEditor, editorService: ICodeEditorService, reference: Location | LocationLink, sideBySide: boolean, highlight: boolean, selectionRange: IRange | undefined): Promise<ICodeEditor | undefined> {
private async _openReference(editor: ICodeEditor, editorService: ICodeEditorService, reference: Location | LocationLink, sideBySide: boolean, highlight: boolean): Promise<ICodeEditor | undefined> {
// range is the target-selection-range when we have one
// and the fallback is the 'full' range
let range: IRange | undefined = undefined;
let selectFullRange = false;
if (selectionRange) {
range = selectionRange;
selectFullRange = true;
} else {
if (isLocationLink(reference)) {
range = reference.targetSelectionRange;
}
if (!range) {
range = reference.range;
}
if (!range) {
return undefined;
}
if (isLocationLink(reference)) {
range = reference.targetSelectionRange;
}
if (!range) {
range = reference.range;
}
if (!range) {
return undefined;
}

const targetEditor = await editorService.openCodeEditor({
resource: reference.uri,
options: {
selection: selectFullRange ? range : Range.collapseToStart(range),
selection: Range.collapseToStart(range),
selectionRevealType: TextEditorSelectionRevealType.NearTopIfOutsideViewport
}
}, editor, sideBySide);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -997,11 +997,6 @@ configurationRegistry.registerConfiguration({
],
markdownDescription: nls.localize('search.searchEditor.doubleClickBehaviour', "Configure effect of double clicking a result in a search editor.")
},
'search.searchEditor.openLocationToMatch': {
type: 'boolean',
default: false,
markdownDescription: nls.localize('search.searchEditor.openLocationToMatch', "When opening a location from the search editor, set selection to first match in line.")
},
'search.searchEditor.reusePriorSearchConfiguration': {
type: 'boolean',
default: false,
Expand Down
16 changes: 2 additions & 14 deletions src/vs/workbench/contrib/searchEditor/browser/searchEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,21 +241,9 @@ export class SearchEditor extends BaseTextEditor<SearchEditorViewState> {
const position = e.target.position;
if (position && behaviour !== 'selectWord') {
const line = this.searchResultEditor.getModel()?.getLineContent(position.lineNumber) ?? '';
const lineMatch = line.match(RESULT_LINE_REGEX);
if (lineMatch) {
if (line.match(RESULT_LINE_REGEX)) {
this.searchResultEditor.setSelection(Range.fromPositions(position));
// Check if we should select the first match
let selectionRange: Range | undefined;
if (this.searchConfig.searchEditor.openLocationToMatch) {
const searchMatchDecoration = this.searchResultEditor.getModel()?.getLineDecorations(position.lineNumber).find(ld => ld.options.description === 'search-editor-find-match');
if (searchMatchDecoration) {
const matchRange = searchMatchDecoration.range;
const offset = lineMatch[1].length + lineMatch[2].length + lineMatch[3].length;
const matchLine = parseInt(lineMatch[2], 10);
selectionRange = new Range(matchLine, matchRange.startColumn - offset, matchLine, matchRange.endColumn - offset);
}
}
this.commandService.executeCommand(behaviour === 'goToLocation' ? 'editor.action.goToDeclaration' : 'editor.action.openDeclarationToTheSide', { selectionRange: selectionRange });
this.commandService.executeCommand(behaviour === 'goToLocation' ? 'editor.action.goToDeclaration' : 'editor.action.openDeclarationToTheSide');
} else if (line.match(FILE_LINE_REGEX)) {
this.searchResultEditor.setSelection(Range.fromPositions(position));
this.commandService.executeCommand('editor.action.peekDefinition');
Expand Down
1 change: 0 additions & 1 deletion src/vs/workbench/services/search/common/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ export interface ISearchConfigurationProperties {
searchEditor: {
doubleClickBehaviour: 'selectWord' | 'goToLocation' | 'openLocationToSide',
reusePriorSearchConfiguration: boolean,
openLocationToMatch: boolean,
defaultNumberOfContextLines: number | null,
experimental: {}
};
Expand Down

0 comments on commit d94b475

Please sign in to comment.