Skip to content
This repository was archived by the owner on May 7, 2021. It is now read-only.

Commit eee0c47

Browse files
committed
If gocode is panicking, prompt to update gocode
- Fixes #530 - Fixes #474 - Fixes #473 - Fixes #471 - Fixes #468 - Fixes #437 - Fixes #433 - Fixes #158 - Fixes joefitzgerald/autocomplete-go#43 - Fixes joefitzgerald/autocomplete-go#51 - Fixes joefitzgerald/autocomplete-go#52
1 parent 9d2f1e5 commit eee0c47

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

lib/autocomplete/gocodeprovider.js

+30
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import {CompositeDisposable} from 'atom'
44
import {isValidEditor} from '../utils'
55
import _ from 'lodash'
6+
import os from 'os'
67

78
class GocodeProvider {
89
constructor (goconfig) {
@@ -227,6 +228,9 @@ class GocodeProvider {
227228
if (!candidates) {
228229
return []
229230
}
231+
if (candidates[0] && candidates[0].class === 'PANIC' && candidates[0].type === 'PANIC' && candidates[0].name === 'PANIC') {
232+
this.bounceGocode()
233+
}
230234
const prefix = editor.getTextInBufferRange([[position.row, position.column - numPrefix], position])
231235
let suffix = false
232236
try {
@@ -630,5 +634,31 @@ class GocodeProvider {
630634
}
631635
return result
632636
}
637+
638+
bounceGocode () {
639+
if (this.panicked) {
640+
return
641+
}
642+
643+
this.panicked = true
644+
const notification = atom.notifications.addError('gocode', {
645+
dismissable: true,
646+
icon: 'flame',
647+
detail: 'gocode is panicking',
648+
description: 'This often happens when you install a new go version, or when you are running an out of date version of `gocode`.' + os.EOL + os.EOL + 'See the <a href="https://github.com/joefitzgerald/go-plus/wiki/FAQ#help-the-only-autocomplete-suggestion-that-i-am-receiving-is-panic">FAQ</a> for more information.' + os.EOL + os.EOL + 'Often, running `gocode close && go get -u github.com/nsf/gocode` is able to fix the issue.' + os.EOL + os.EOL + 'If this does not work and you are definitely running the latest version of `gocode`, you might want to search for open issues at <a href="https://github.com/nsf/gocode/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aopen%20panic">https://github.com/nsf/gocode/issues</a>.' + os.EOL + os.EOL + 'Would you like to try running `gocode close && go get -u github.com/nsf/gocode` now?',
649+
buttons: [{
650+
text: 'Yes',
651+
onDidClick: () => {
652+
notification.dismiss()
653+
atom.commands.dispatch(atom.views.getView(atom.workspace), 'golang:update-tools', ['github.com/nsf/gocode'])
654+
}
655+
}, {
656+
text: 'Not Now',
657+
onDidClick: () => {
658+
notification.dismiss()
659+
}
660+
}]
661+
})
662+
}
633663
}
634664
export {GocodeProvider}

0 commit comments

Comments
 (0)