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

Allow local files in descriptionMoreURL #762 #763

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/suggestion-list-element.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
SnippetParser = require './snippet-parser'
{isString} = require('./type-helpers')
fuzzaldrinPlus = require 'fuzzaldrin-plus'
shell = require('electron').shell

ItemTemplate = """
<span class="icon-container"></span>
Expand Down Expand Up @@ -107,7 +108,9 @@ class SuggestionListElement extends HTMLElement
@descriptionContent.textContent = item.description
if item.descriptionMoreURL? and item.descriptionMoreURL.length?
@descriptionMoreLink.style.display = 'inline'
@descriptionMoreLink.setAttribute('href', item.descriptionMoreURL)
@descriptionMoreLink.onclick = (event) ->
shell.openExternal(item.descriptionMoreURL)
event.stopPropagation()
else
@descriptionMoreLink.style.display = 'none'
@descriptionMoreLink.setAttribute('href', '#')
Expand Down
27 changes: 26 additions & 1 deletion spec/provider-api-spec.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{waitForAutocomplete, triggerAutocompletion} = require './spec-helper'
shell = require('electron').shell

describe 'Provider API', ->
[completionDelay, editor, mainModule, autocompleteManager, registration, testProvider] = []
Expand All @@ -16,6 +17,8 @@ describe 'Provider API', ->

workspaceElement = atom.views.getView(atom.workspace)
jasmine.attachToDOM(workspaceElement)

spyOn(shell, "openExternal")

# Activate the package
waitsForPromise ->
Expand Down Expand Up @@ -139,7 +142,29 @@ describe 'Provider API', ->
expect(content).toHaveText('There be documentation')
expect(moreLink).toHaveText('More..')
expect(moreLink.style.display).toBe 'inline'
expect(moreLink.getAttribute('href')).toBe 'http://google.com'
expect(moreLink.onclick).toBeDefined()

it 'correctly handles More link', ->
testProvider =
scopeSelector: '.source.js, .source.coffee'
getSuggestions: (options) ->
[
text: 'ohai',
replacementPrefix: 'o',
rightLabelHTML: '<span style="color: red">ohai</span>',
description: 'There be documentation'
descriptionMoreURL: 'http://google.com'
]
registration = atom.packages.serviceHub.provide('autocomplete.provider', '2.0.0', testProvider)

triggerAutocompletion(editor, true, 'o')

runs ->
suggestionListView = atom.views.getView(autocompleteManager.suggestionList)
moreLink = suggestionListView.querySelector('.suggestion-description-more-link')
expect(moreLink.onclick).toBeDefined()
moreLink.onclick(stopPropagation: ->)
expect(shell.openExternal).toHaveBeenCalledWith('http://google.com')

describe "when the filterSuggestions option is set to true", ->
getSuggestions = ->
Expand Down