Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[READY] Filter and sort candidates when query is empty #819

Merged
merged 1 commit into from
Aug 29, 2017

Conversation

micbou
Copy link
Collaborator

@micbou micbou commented Aug 26, 2017

An obvious reason to sort the candidates with our FilterAndSortCandidates function even if the query is empty is that returning candidates in lexicographical order is better than in random order. Consider this example in JavaScript:

sort-on-empty-query

Another reason is that some semantic engines (Jedi, TSServer, Gocode, and C#) return the candidates sorted (generally in lexicographical order) while others don't (Clang, Tern, and racer). Thus, the order of candidates depends on the completer when the query is empty. This is inconsistent.

That's not all. In addition to sorting, FilterAndSortCandidates filters candidates that are too long (more than 80 characters) or contain non-ASCII characters. Not filtering them when the query is empty leads to confusion. For instance:

empty-query-non-ascii
Why did the foø candidate disappear?!

Last point (which is an implementation detail) is that this is going to help implementing partial sorting (and limiting the number of candidates returned) because we won't have to handle the case where the query is empty.


This change is Reviewable

@codecov-io
Copy link

codecov-io commented Aug 26, 2017

Codecov Report

Merging #819 into master will increase coverage by 0.05%.
The diff coverage is 70%.

@@            Coverage Diff             @@
##           master     #819      +/-   ##
==========================================
+ Coverage   94.78%   94.84%   +0.05%     
==========================================
  Files          79       79              
  Lines        5373     5373              
  Branches      170      169       -1     
==========================================
+ Hits         5093     5096       +3     
+ Misses        233      231       -2     
+ Partials       47       46       -1

@vheon
Copy link
Contributor

vheon commented Aug 27, 2017

:lgtm:


Reviewed 9 of 9 files at r1.
Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed.


Comments from Reviewable

@Valloric
Copy link
Member

:lgtm:

Thanks!

@zzbot r=vheon


Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed.


Comments from Reviewable

@zzbot
Copy link
Contributor

zzbot commented Aug 29, 2017

📌 Commit 1754b66 has been approved by vheon

@zzbot
Copy link
Contributor

zzbot commented Aug 29, 2017

⌛ Testing commit 1754b66 with merge de888d8...

zzbot added a commit that referenced this pull request Aug 29, 2017
[READY] Filter and sort candidates when query is empty

An obvious reason to sort the candidates with our `FilterAndSortCandidates` function even if the query is empty is that returning candidates in lexicographical order is better than in random order. Consider this example in JavaScript:

![sort-on-empty-query](https://user-images.githubusercontent.com/10026824/29744137-263ede40-8a9f-11e7-8b2c-4f3c35dbcd66.png)

Another reason is that some semantic engines (Jedi, TSServer, Gocode, and C#) return the candidates sorted (generally in lexicographical order) while others don't (Clang, Tern, and racer). Thus, the order of candidates depends on the completer when the query is empty. This is inconsistent.

That's not all. In addition to sorting, `FilterAndSortCandidates` filters candidates that are too long (more than 80 characters) or contain non-ASCII characters. Not filtering them when the query is empty leads to confusion. For instance:

![empty-query-non-ascii](https://user-images.githubusercontent.com/10026824/29744379-2220dc46-8aa4-11e7-963d-c473e555bb01.gif)
*Why did the `foø` candidate disappear?!*

Last point (which is an implementation detail) is that this is going to help implementing partial sorting (and limiting the number of candidates returned) because we won't have to handle the case where the query is empty.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/ycmd/819)
<!-- Reviewable:end -->
@zzbot
Copy link
Contributor

zzbot commented Aug 29, 2017

☀️ Test successful - status-travis
Approved by: vheon
Pushing de888d8 to master...

@zzbot zzbot merged commit 1754b66 into ycm-core:master Aug 29, 2017
@micbou micbou deleted the sort-on-empty-query branch August 29, 2017 02:30
zzbot added a commit that referenced this pull request Aug 30, 2017
[READY] Do not sort header paths in filename completer

There is no point in sorting header paths and removing duplicates by converting the list to a set in the filename completer since the paths are going through the `FilterAndSortCandidates` function even when the query is empty (thanks to PR #819).

Rewrite the filename completer tests to use the `contains_inanyorder` and `empty` matchers.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/ycmd/824)
<!-- Reviewable:end -->
zzbot added a commit to ycm-core/YouCompleteMe that referenced this pull request Sep 10, 2017
[READY] Update ycmd

This new version of ycmd includes the following changes:

 - PR ycm-core/ycmd#795: add option to make relative paths in flags from extra conf absolute;
 - PR ycm-core/ycmd#802: fix compilation on Haiku;
 - PR ycm-core/ycmd#804: add libclang detection on FreeBSD;
 - PR ycm-core/ycmd#808: write python used during build before installing completers;
 - PR ycm-core/ycmd#810: support unknown languages from tags;
 - PR ycm-core/ycmd#811: update Universal Ctags languages list;
 - PR ycm-core/ycmd#814: resolve symlinks in extra conf glob patterns;
 - PR ycm-core/ycmd#815: update JediHTTP;
 - PR ycm-core/ycmd#816: update Boost to 1.65.0;
 - PR ycm-core/ycmd#819: filter and sort candidates when query is empty;
 - PR ycm-core/ycmd#820: improve LLVM root path search for prebuilt binaries;
 - PR ycm-core/ycmd#822: inline critical utility functions;
 - PR ycm-core/ycmd#824: do not sort header paths in filename completer;
 - PR ycm-core/ycmd#825: implement partial sorting;
 - PR ycm-core/ycmd#830: add max_num_candidates option;
 - PR ycm-core/ycmd#831: fix multiline comments and strings issues;
 - PR ycm-core/ycmd#832: update Clang to 5.0.0.

The `g:ycm_max_num_candidates` and `g:ycm_max_num_identifier_candidates` options are added to the documentation.

The link to ycmd extra conf is updated.

Fixes #2562.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2768)
<!-- Reviewable:end -->
zzbot added a commit to ycm-core/YouCompleteMe that referenced this pull request Sep 10, 2017
[READY] Update ycmd

This new version of ycmd includes the following changes:

 - PR ycm-core/ycmd#795: add option to make relative paths in flags from extra conf absolute;
 - PR ycm-core/ycmd#802: fix compilation on Haiku;
 - PR ycm-core/ycmd#804: add libclang detection on FreeBSD;
 - PR ycm-core/ycmd#808: write python used during build before installing completers;
 - PR ycm-core/ycmd#810: support unknown languages from tags;
 - PR ycm-core/ycmd#811: update Universal Ctags languages list;
 - PR ycm-core/ycmd#814: resolve symlinks in extra conf glob patterns;
 - PR ycm-core/ycmd#815: update JediHTTP;
 - PR ycm-core/ycmd#816: update Boost to 1.65.0;
 - PR ycm-core/ycmd#819: filter and sort candidates when query is empty;
 - PR ycm-core/ycmd#820: improve LLVM root path search for prebuilt binaries;
 - PR ycm-core/ycmd#822: inline critical utility functions;
 - PR ycm-core/ycmd#824: do not sort header paths in filename completer;
 - PR ycm-core/ycmd#825: implement partial sorting;
 - PR ycm-core/ycmd#830: add max_num_candidates option;
 - PR ycm-core/ycmd#831: fix multiline comments and strings issues;
 - PR ycm-core/ycmd#832: update Clang to 5.0.0.

The `g:ycm_max_num_candidates` and `g:ycm_max_num_identifier_candidates` options are added to the documentation.

The link to ycmd extra conf is updated.

Fixes #2562.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2768)
<!-- Reviewable:end -->
ptrv added a commit to ptrv/emacs-ycmd that referenced this pull request Oct 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants