This repository has been archived by the owner on Apr 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 298
De-deduplicate completion items + improve sorting #2638
Merged
akinsho
merged 2 commits into
onivim:master
from
feltech:feature/completion_dedupe_and_improved_sorting
Oct 22, 2018
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
browser/test/Services/Completion/CompletionSelectorsTests.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import * as assert from "assert" | ||
import { CompletionItem } from "vscode-languageserver-types" | ||
|
||
import { filterCompletionOptions } from "../../../src/Services/Completion/CompletionSelectors" | ||
|
||
describe("filterCompletionOptions", () => { | ||
it("strips duplicates and sorts in order of abbreviation=>label=>sortText", () => { | ||
const item1: CompletionItem = { | ||
label: "mock duplicate", | ||
detail: "mock detail", | ||
sortText: "c", | ||
} | ||
const item2: CompletionItem = { | ||
label: "mock duplicate", | ||
detail: "mock detail", | ||
sortText: "b", | ||
} | ||
const item3: CompletionItem = { | ||
label: "mock duplicate", | ||
detail: "mock not duplicate detail", | ||
sortText: "a", | ||
} | ||
const item4: CompletionItem = { | ||
label: "maaaaoaaaacaaaak abbreviation", | ||
} | ||
const item5: CompletionItem = { | ||
label: "mock cherry", | ||
filterText: "mock cherry", | ||
} | ||
const item6: CompletionItem = { | ||
label: "mock cherry", | ||
filterText: "mock banana", | ||
} | ||
const item7: CompletionItem = { | ||
label: "mock apple", | ||
} | ||
const item8: CompletionItem = { | ||
label: "doesnt match", | ||
} | ||
const item9: CompletionItem = { | ||
label: "mock apple", | ||
filterText: "doesnt match either", | ||
} | ||
const items: CompletionItem[] = [ | ||
item1, | ||
item2, | ||
item3, | ||
item4, | ||
item5, | ||
item6, | ||
item7, | ||
item8, | ||
item9, | ||
] | ||
|
||
const filteredItems = filterCompletionOptions(items, "mock") | ||
|
||
assert.deepStrictEqual(filteredItems, [item7, item6, item5, item3, item2, item4]) | ||
}) | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@feltech if you import just the specific functions you need rather than
_
from lodash this will help reduce our bundle size which is something we should aim for but probably don't get right in many situationse.g.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Done.