@@ -14,6 +14,7 @@ import {
14
14
isValidWordToInspect
15
15
} from '../misc/words'
16
16
import { getLocalContext } from '../misc/blocks'
17
+ import { show } from '../ui/selector'
17
18
18
19
const {
19
20
gotosymbol : gotoSymbol ,
@@ -68,6 +69,28 @@ class Goto {
68
69
return client . isActive ( ) && this . ink !== undefined
69
70
}
70
71
72
+ // TODO: handle remote files ?
73
+ selectItemsAndGo ( items ) {
74
+ if ( items . length === 0 ) return
75
+ if ( items . length === 1 ) {
76
+ const item = items [ 0 ]
77
+ return this . ink . Opener . open ( item . file , item . line , {
78
+ pending : atom . config . get ( 'core.allowPendingPaneItems' )
79
+ } )
80
+ }
81
+ items = items . map ( result => {
82
+ result . primary = result . text
83
+ result . secondary = `${ result . file } :${ result . line } `
84
+ return result
85
+ } )
86
+ return show ( items ) . then ( item => {
87
+ if ( ! item ) return
88
+ this . ink . Opener . open ( item . file , item . line , {
89
+ pending : atom . config . get ( 'core.allowPendingPaneItems' )
90
+ } )
91
+ } )
92
+ }
93
+
71
94
gotoSymbol ( ) {
72
95
const editor = atom . workspace . getActiveTextEditor ( )
73
96
const bufferPosition = editor . getCursorBufferPosition ( )
@@ -76,9 +99,8 @@ class Goto {
76
99
const rangeFilePath = this . getJumpFilePath ( editor , bufferPosition )
77
100
if ( rangeFilePath ) {
78
101
const { filePath } = rangeFilePath
79
- return atom . workspace . open ( filePath , {
102
+ return this . ink . Opener . open ( filePath , 0 , {
80
103
pending : atom . config . get ( 'core.allowPendingPaneItems' ) ,
81
- searchAllPanes : true
82
104
} )
83
105
}
84
106
@@ -103,7 +125,7 @@ class Goto {
103
125
const mod = currentModule ? currentModule : 'Main'
104
126
const text = editor . getText ( ) // buffer text that will be used for fallback entry
105
127
106
- gotoSymbol ( {
128
+ return gotoSymbol ( {
107
129
word,
108
130
path : editor . getPath ( ) || 'untitled-' + editor . getBuffer ( ) . getId ( ) ,
109
131
// local context
@@ -117,9 +139,7 @@ class Goto {
117
139
text
118
140
} ) . then ( results => {
119
141
if ( results . error ) return
120
- this . ink . goto . goto ( results , {
121
- pending : atom . config . get ( 'core.allowPendingPaneItems' )
122
- } )
142
+ this . selectItemsAndGo ( results . items )
123
143
} ) . catch ( err => {
124
144
console . log ( err )
125
145
} )
@@ -134,9 +154,8 @@ class Goto {
134
154
return {
135
155
range,
136
156
callback : ( ) => {
137
- atom . workspace . open ( filePath , {
157
+ return this . ink . Opener . open ( filePath , 0 , {
138
158
pending : atom . config . get ( 'core.allowPendingPaneItems' ) ,
139
- searchAllPanes : true
140
159
} )
141
160
}
142
161
}
@@ -190,13 +209,7 @@ class Goto {
190
209
}
191
210
resolve ( {
192
211
range,
193
- callback : ( ) => {
194
- setTimeout ( ( ) => {
195
- this . ink . goto . goto ( results , {
196
- pending : atom . config . get ( 'core.allowPendingPaneItems' )
197
- } )
198
- } , 5 )
199
- }
212
+ callback : ( ) => setTimeout ( ( ) => this . selectItemsAndGo ( results . items ) , 5 )
200
213
} )
201
214
} ) . catch ( err => {
202
215
console . log ( err )
0 commit comments