mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Removing text from Autocomplete's mini-editor refilters match list
This commit is contained in:
@@ -166,7 +166,19 @@ describe "Autocomplete", ->
|
||||
expect(autocomplete.find('li:eq(0)')).toHaveClass('selected')
|
||||
expect(autocomplete.find('li:eq(1)')).not.toHaveClass('selected')
|
||||
|
||||
describe "when the mini-editor receives text input", ->
|
||||
describe "when the mini-editor's buffer changes", ->
|
||||
describe "when text is removed from the mini-editor", ->
|
||||
it "reloads the match list based on the mini-editor's text", ->
|
||||
editor.buffer.insert([10,0] ,"t")
|
||||
editor.setCursorBufferPosition([10,0])
|
||||
autocomplete.attach()
|
||||
|
||||
expect(autocomplete.matchesList.find('li').length).toBe 8
|
||||
miniEditor.textInput('c')
|
||||
expect(autocomplete.matchesList.find('li').length).toBe 3
|
||||
miniEditor.backspace()
|
||||
expect(autocomplete.matchesList.find('li').length).toBe 8
|
||||
|
||||
describe "when the text contains only word characters", ->
|
||||
it "narrows the list of completions with the fuzzy match algorithm", ->
|
||||
editor.buffer.insert([10,0] ,"t")
|
||||
|
||||
@@ -37,8 +37,9 @@ class Autocomplete extends View
|
||||
@on 'autocomplete:confirm', => @confirm()
|
||||
@on 'autocomplete:cancel', => @cancel()
|
||||
|
||||
@miniEditor.buffer.on 'change', =>
|
||||
@filterMatchList() if @parent()[0]
|
||||
@miniEditor.buffer.on 'change', (e) =>
|
||||
return unless @parent()[0]
|
||||
@filterMatchList()
|
||||
|
||||
@miniEditor.preempt 'move-up', =>
|
||||
@selectPreviousMatch()
|
||||
@@ -121,13 +122,14 @@ class Autocomplete extends View
|
||||
|
||||
if (prefix.length + suffix.length) > 0
|
||||
currentWord = prefix + @editor.getSelectedText() + suffix
|
||||
@matches = (match for match in @wordMatches(prefix, suffix) when match.word != currentWord)
|
||||
@baseMatches = (match for match in @wordMatches(prefix, suffix) when match.word != currentWord)
|
||||
else
|
||||
@matches = []
|
||||
@renderMatchList()
|
||||
@baseMatches = []
|
||||
|
||||
@filterMatchList()
|
||||
|
||||
filterMatchList: ->
|
||||
@matches = fuzzyFilter(@matches, @miniEditor.buffer.getText(), key: 'word')
|
||||
@matches = fuzzyFilter(@baseMatches, @miniEditor.getText(), key: 'word')
|
||||
@renderMatchList()
|
||||
|
||||
renderMatchList: ->
|
||||
|
||||
Reference in New Issue
Block a user