Skip to content

Commit 2f37768

Browse files
authored
Merge pull request #733 from JunoLab/avi/noinkgoto
just use julia-client's selector
2 parents 40900ec + 657ebce commit 2f37768

File tree

3 files changed

+38
-27
lines changed

3 files changed

+38
-27
lines changed

lib/runtime/goto.js

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
isValidWordToInspect
1515
} from '../misc/words'
1616
import { getLocalContext } from '../misc/blocks'
17+
import { show } from '../ui/selector'
1718

1819
const {
1920
gotosymbol: gotoSymbol,
@@ -68,6 +69,28 @@ class Goto {
6869
return client.isActive() && this.ink !== undefined
6970
}
7071

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+
7194
gotoSymbol () {
7295
const editor = atom.workspace.getActiveTextEditor()
7396
const bufferPosition = editor.getCursorBufferPosition()
@@ -76,9 +99,8 @@ class Goto {
7699
const rangeFilePath = this.getJumpFilePath(editor, bufferPosition)
77100
if (rangeFilePath) {
78101
const { filePath } = rangeFilePath
79-
return atom.workspace.open(filePath, {
102+
return this.ink.Opener.open(filePath, 0, {
80103
pending: atom.config.get('core.allowPendingPaneItems'),
81-
searchAllPanes: true
82104
})
83105
}
84106

@@ -103,7 +125,7 @@ class Goto {
103125
const mod = currentModule ? currentModule : 'Main'
104126
const text = editor.getText() // buffer text that will be used for fallback entry
105127

106-
gotoSymbol({
128+
return gotoSymbol({
107129
word,
108130
path: editor.getPath() || 'untitled-' + editor.getBuffer().getId(),
109131
// local context
@@ -117,9 +139,7 @@ class Goto {
117139
text
118140
}).then(results => {
119141
if (results.error) return
120-
this.ink.goto.goto(results, {
121-
pending: atom.config.get('core.allowPendingPaneItems')
122-
})
142+
this.selectItemsAndGo(results.items)
123143
}).catch(err => {
124144
console.log(err)
125145
})
@@ -134,9 +154,8 @@ class Goto {
134154
return {
135155
range,
136156
callback: () => {
137-
atom.workspace.open(filePath, {
157+
return this.ink.Opener.open(filePath, 0, {
138158
pending: atom.config.get('core.allowPendingPaneItems'),
139-
searchAllPanes: true
140159
})
141160
}
142161
}
@@ -190,13 +209,7 @@ class Goto {
190209
}
191210
resolve({
192211
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)
200213
})
201214
}).catch(err => {
202215
console.log(err)

lib/runtime/workspace.coffee

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{CompositeDisposable} = require 'atom'
22

3-
{views} = require '../ui'
43
{client} = require '../connection'
5-
4+
{views} = require '../ui'
5+
goto = require './goto'
66
modules = require './modules'
77

88
{ workspace, gotosymbol: gotoSymbol, clearLazy } = client.import rpc: ['workspace', 'gotosymbol'], msg: 'clearLazy'
@@ -42,10 +42,9 @@ module.exports =
4242
gotoSymbol
4343
word: name,
4444
mod: mod
45-
.then (symbols) =>
46-
return if symbols.error
47-
@ink.goto.goto symbols,
48-
pending: atom.config.get('core.allowPendingPaneItems')
45+
.then (results) =>
46+
return if results.error
47+
goto.selectItemsAndGo(results.items)
4948

5049
create: ->
5150
@ws = @ink.Workspace.fromId 'julia'

lib/ui/docs.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
'use babel'
22

3-
import { client } from '../connection'
43
import { CompositeDisposable } from 'atom'
4+
import { client } from '../connection'
55
const views = require('./views')
6+
import goto from '../runtime/goto'
67

78
const {
89
searchdocs: searchDocs,
@@ -74,11 +75,9 @@ export function processItem (item) {
7475
gotoSymbol({
7576
word: item.name,
7677
mod: item.mod
77-
}).then(symbols => {
78-
if (symbols.error) return
79-
ink.goto.goto(symbols, {
80-
pending: atom.config.get('core.allowPendingPaneItems')
81-
})
78+
}).then(results => {
79+
if (results.error) return
80+
return goto.selectItemsAndGo(results.items)
8281
})
8382
}
8483

0 commit comments

Comments
 (0)