@@ -12,10 +12,10 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
1212import { EditorAction , IActionOptions , registerEditorAction , ServicesAccessor } from 'vs/editor/browser/editorExtensions' ;
1313import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService' ;
1414import * as corePosition from 'vs/editor/common/core/position' ;
15- import { Range } from 'vs/editor/common/core/range' ;
15+ import { Range , IRange } from 'vs/editor/common/core/range' ;
1616import { EditorContextKeys } from 'vs/editor/common/editorContextKeys' ;
1717import { ITextModel , IWordAtPosition } from 'vs/editor/common/model' ;
18- import { LocationLink , Location } from 'vs/editor/common/modes' ;
18+ import { LocationLink , Location , isLocationLink } from 'vs/editor/common/modes' ;
1919import { MessageController } from 'vs/editor/contrib/message/messageController' ;
2020import { PeekContext } from 'vs/editor/contrib/referenceSearch/peekViewWidget' ;
2121import { ReferencesController } from 'vs/editor/contrib/referenceSearch/referencesController' ;
@@ -29,7 +29,6 @@ import { IProgressService } from 'vs/platform/progress/common/progress';
2929import { getDefinitionsAtPosition , getImplementationsAtPosition , getTypeDefinitionsAtPosition , getDeclarationsAtPosition } from './goToDefinition' ;
3030import { CommandsRegistry } from 'vs/platform/commands/common/commands' ;
3131
32-
3332export class DefinitionActionConfig {
3433
3534 constructor (
@@ -44,7 +43,7 @@ export class DefinitionActionConfig {
4443
4544export class DefinitionAction extends EditorAction {
4645
47- private _configuration : DefinitionActionConfig ;
46+ private readonly _configuration : DefinitionActionConfig ;
4847
4948 constructor ( configuration : DefinitionActionConfig , opts : IActionOptions ) {
5049 super ( opts ) ;
@@ -74,14 +73,10 @@ export class DefinitionAction extends EditorAction {
7473 if ( ! reference || ! reference . range ) {
7574 continue ;
7675 }
77- let { uri, range } = reference ;
78- let newLen = result . push ( {
79- uri,
80- range
81- } ) ;
76+ const newLen = result . push ( reference ) ;
8277 if ( this . _configuration . filterCurrent
83- && uri . toString ( ) === model . uri . toString ( )
84- && Range . containsPosition ( range , pos )
78+ && reference . uri . toString ( ) === model . uri . toString ( )
79+ && Range . containsPosition ( reference . range , pos )
8580 && idxOfCurrent === - 1
8681 ) {
8782 idxOfCurrent = newLen - 1 ;
@@ -145,11 +140,21 @@ export class DefinitionAction extends EditorAction {
145140 }
146141 }
147142
148- private _openReference ( editor : ICodeEditor , editorService : ICodeEditorService , reference : Location , sideBySide : boolean ) : Promise < ICodeEditor > {
143+ private _openReference ( editor : ICodeEditor , editorService : ICodeEditorService , reference : Location | LocationLink , sideBySide : boolean ) : Promise < ICodeEditor > {
144+ // range is the target-selection-range when we have one
145+ // and the the fallback is the 'full' range
146+ let range : IRange = undefined ;
147+ if ( isLocationLink ( reference ) ) {
148+ range = reference . targetSelectionRange ;
149+ }
150+ if ( ! range ) {
151+ range = reference . range ;
152+ }
153+
149154 return editorService . openCodeEditor ( {
150155 resource : reference . uri ,
151156 options : {
152- selection : Range . collapseToStart ( reference . range ) ,
157+ selection : Range . collapseToStart ( range ) ,
153158 revealIfOpened : true ,
154159 revealInCenterIfOutsideViewport : true
155160 }
0 commit comments