Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Add keybinding to descriptionMoreUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
Pontus committed Nov 11, 2017
1 parent 016c268 commit 05f2c81
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions keymaps/autocomplete-plus.cson
Expand Up @@ -3,3 +3,4 @@

'atom-text-editor.autocomplete-active':
'escape': 'autocomplete-plus:cancel'
'f1': 'autocomplete-plus:navigate-to-description-more-link'
8 changes: 8 additions & 0 deletions lib/autocomplete-manager.js
Expand Up @@ -213,6 +213,14 @@ class AutocompleteManager {
activatedManually = event.detail.activatedManually
}
this.findSuggestions(activatedManually)
},
'autocomplete-plus:navigate-to-description-more-link': () => {
let suggestionListView = atom.views.getView(this.editor);
let descriptionContainer = suggestionListView.querySelector('.suggestion-description');
if (descriptionContainer.style.display === 'block') {
let descriptionMoreLink = descriptionContainer.querySelector('.suggestion-description-more-link');

This comment has been minimized.

Copy link
@mciek
require('shell').openExternal(descriptionMoreLink.href);
}
}
}))
}
Expand Down
17 changes: 17 additions & 0 deletions spec/autocomplete-manager-integration-spec.js
Expand Up @@ -2032,6 +2032,23 @@ defm`
})
})
})

describe('Keybind to navigate to descriptionMoreLink', () => {
it('triggers openExternal on keybind', () => {

spyOn(provider, 'getSuggestions').andCallFake(() => [{text: 'ab', description: 'it is ab'}])
let shell = require('shell')
spyOn(shell, 'openExternal')

triggerAutocompletion(editor, true, 'a')

runs(() => {
expect(editorView.querySelector('.autocomplete-plus')).toExist()
atom.commands.dispatch(editorView, 'autocomplete-plus:navigate-to-description-more-link')
expect(shell.openExternal).toHaveBeenCalled()
})
})
})
})

describe('when opening a file without a path', () => {
Expand Down

0 comments on commit 05f2c81

Please sign in to comment.