Merge pull request #1906 from ngavalas/autocomplete-trigger-prefix

fix non-. prefix triggers overfiltering results
This commit is contained in:
w0rp
2018-09-14 13:32:25 +01:00
committed by GitHub
2 changed files with 24 additions and 10 deletions

View File

@@ -12,16 +12,17 @@ After:
Execute(Prefix filtering should work for Lists of strings):
AssertEqual
\ ['FooBar', 'foo'],
\ ale#completion#Filter(bufnr(''), ['FooBar', 'FongBar', 'baz', 'foo'], 'foo')
\ ale#completion#Filter(bufnr(''), '', ['FooBar', 'FongBar', 'baz', 'foo'], 'foo')
AssertEqual
\ ['FooBar', 'FongBar', 'baz', 'foo'],
\ ale#completion#Filter(bufnr(''), ['FooBar', 'FongBar', 'baz', 'foo'], '.')
\ ale#completion#Filter(bufnr(''), '', ['FooBar', 'FongBar', 'baz', 'foo'], '.')
Execute(Prefix filtering should work for completion items):
AssertEqual
\ [{'word': 'FooBar'}, {'word': 'foo'}],
\ ale#completion#Filter(
\ bufnr(''),
\ '',
\ [
\ {'word': 'FooBar'},
\ {'word': 'FongBar'},
@@ -40,6 +41,7 @@ Execute(Prefix filtering should work for completion items):
\ ],
\ ale#completion#Filter(
\ bufnr(''),
\ '',
\ [
\ {'word': 'FooBar'},
\ {'word': 'FongBar'},
@@ -56,6 +58,7 @@ Execute(Excluding words from completion results should work):
\ [{'word': 'Italian'}],
\ ale#completion#Filter(
\ bufnr(''),
\ '',
\ [
\ {'word': 'Italian'},
\ {'word': 'it'},
@@ -67,6 +70,7 @@ Execute(Excluding words from completion results should work):
\ [{'word': 'Deutsch'}],
\ ale#completion#Filter(
\ bufnr(''),
\ '',
\ [
\ {'word': 'describe'},
\ {'word': 'Deutsch'},
@@ -78,6 +82,7 @@ Execute(Excluding words from completion results should work):
\ [{'word': 'Deutsch'}],
\ ale#completion#Filter(
\ bufnr(''),
\ '',
\ [
\ {'word': 'describe'},
\ {'word': 'Deutsch'},
@@ -90,19 +95,26 @@ Execute(Excluding words from completion results should work with lists of String
AssertEqual
\ ['Italian'],
\ ale#completion#Filter(bufnr(''), ['Italian', 'it'], 'it')
\ ale#completion#Filter(bufnr(''), '', ['Italian', 'it'], 'it')
AssertEqual
\ ['Deutsch'],
\ ale#completion#Filter(bufnr(''), ['describe', 'Deutsch'], 'de')
\ ale#completion#Filter(bufnr(''), '', ['describe', 'Deutsch'], 'de')
AssertEqual
\ ['Deutsch'],
\ ale#completion#Filter(bufnr(''), ['describe', 'Deutsch'], '.')
\ ale#completion#Filter(bufnr(''), '', ['describe', 'Deutsch'], '.')
Execute(Filtering shouldn't modify the original list):
let b:ale_completion_excluded_words = ['it', 'describe']
let b:suggestions = [{'word': 'describe'}]
AssertEqual [], ale#completion#Filter(bufnr(''), b:suggestions, '.')
AssertEqual [], ale#completion#Filter(bufnr(''), '', b:suggestions, '.')
AssertEqual b:suggestions, [{'word': 'describe'}]
AssertEqual [], ale#completion#Filter(bufnr(''), b:suggestions, 'de')
AssertEqual [], ale#completion#Filter(bufnr(''), '', b:suggestions, 'de')
AssertEqual b:suggestions, [{'word': 'describe'}]
Execute(Filtering should respect filetype triggers):
let b:suggestions = [{'word': 'describe'}]
AssertEqual b:suggestions, ale#completion#Filter(bufnr(''), '', b:suggestions, '.')
AssertEqual b:suggestions, ale#completion#Filter(bufnr(''), 'rust', b:suggestions, '.')
AssertEqual b:suggestions, ale#completion#Filter(bufnr(''), 'rust', b:suggestions, '::')