Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

De-deduplicate completion items + improve sorting #2638

Merged

Conversation

feltech
Copy link
Contributor

@feltech feltech commented Oct 16, 2018

  • Remove duplicate completion items. This seems to happen a lot with cquery (C++) completions.
  • Continue to sort abbreviations below full matches.
  • Sort matching filterText/labels so they appear next to each other.
  • Otherwise use sortText given by the language server.

* Remove completion items that are duplicates for all attributes other
than `sortText` (which is always different but is just some
machine-readable hash for sorting by).
* Continue to sort abbreviations below full matches.
* Sort matching `filterText`/`labels` so they appear next to each other.
* Otherwise use `sortText` given by the language server.
@feltech
Copy link
Contributor Author

feltech commented Oct 16, 2018

The main motivation for this PR was to remove the duplicates coming back from cquery.

However, I found that the sort order of results was odd (which makes filtering duplicates more expensive, and just looks strange). Perhaps they make some sense straight from the language server, but Oni then filters as the user types, so retaining the sort order from the language server makes even less sense.

Hence why I thought it reasonable to "fix" the sort order for filtered completions.

@@ -3,6 +3,7 @@
*
* Selectors are functions that take a state and derive a value from it.
*/
import * as _ from "lodash"
Copy link
Member

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 situations

e.g.

import uniq from "lodash/uniq"
// or if type issues
import * as omit from "lodash/omit"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Done.

@codecov
Copy link

codecov bot commented Oct 17, 2018

Codecov Report

Merging #2638 into master will increase coverage by 0.07%.
The diff coverage is 88.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2638      +/-   ##
==========================================
+ Coverage   45.43%   45.51%   +0.07%     
==========================================
  Files         361      361              
  Lines       14563    14591      +28     
  Branches     1912     1919       +7     
==========================================
+ Hits         6617     6641      +24     
- Misses       7721     7723       +2     
- Partials      225      227       +2
Impacted Files Coverage Δ
...ser/src/Services/Completion/CompletionSelectors.ts 76.56% <88.23%> (+7.11%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2ae1224...4ef58f9. Read the comment docs.

Copy link
Member

@akinsho akinsho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍looks good now with all tests passing thanks for the contribution @feltech

Copy link
Member

@akinsho akinsho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good thanks for the contribution @feltech 👍

@akinsho akinsho merged commit b9a2992 into onivim:master Oct 22, 2018
@feltech feltech deleted the feature/completion_dedupe_and_improved_sorting branch October 23, 2018 11:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants