Skip to content

Commit bf13717

Browse files
authored
Include page titles in autocomplete (#1537)
1 parent e132398 commit bf13717

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

assets/js/autocomplete/suggestions.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import { escapeRegexModifiers, escapeHtmlEntities, isBlank } from '../helpers'
1515
const SUGGESTION_CATEGORY = {
1616
module: 'module',
1717
moduleChild: 'module-child',
18-
mixTask: 'mix-task'
18+
mixTask: 'mix-task',
19+
extra: 'extra'
1920
}
2021

2122
/**
@@ -35,7 +36,8 @@ export function getSuggestions (query, limit = 5) {
3536
const suggestions = [
3637
...findSuggestionsInTopLevelNodes(nodes.modules, query, SUGGESTION_CATEGORY.module),
3738
...findSuggestionsInChildNodes(nodes.modules, query, SUGGESTION_CATEGORY.moduleChild),
38-
...findSuggestionsInTopLevelNodes(nodes.tasks, query, SUGGESTION_CATEGORY.mixTask)
39+
...findSuggestionsInTopLevelNodes(nodes.tasks, query, SUGGESTION_CATEGORY.mixTask),
40+
...findSuggestionsInTopLevelNodes(nodes.extras, query, SUGGESTION_CATEGORY.extra)
3941
]
4042

4143
return sort(suggestions).slice(0, limit)

assets/test/autocomplete/suggestions.spec.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,11 @@ describe('getSuggestions', () => {
5959
})
6060

6161
describe('find', () => {
62-
it('returns matching modules, tasks and exceptions', () => {
62+
it('returns matching modules, tasks, extras and exceptions', () => {
6363
expect(getSuggestions('Map').length).to.eql(1)
6464
expect(getSuggestions('Ecto.Repo').length).to.eql(1)
6565
expect(getSuggestions('phx.server').length).to.eql(1)
66+
expect(getSuggestions('API Reference').length).to.eql(1)
6667
expect(getSuggestions('My exception').length).to.eql(1)
6768
})
6869

@@ -72,10 +73,6 @@ describe('getSuggestions', () => {
7273
expect(getSuggestions('has_many').length).to.eql(1)
7374
})
7475

75-
it('ignores matching extras', () => {
76-
expect(getSuggestions('api-reference').length).to.eql(0)
77-
})
78-
7976
it('handles special characters', () => {
8077
expect(getSuggestions('&&/2').length).to.eql(1)
8178
expect(getSuggestions('<>').length).to.eql(1)

0 commit comments

Comments
 (0)