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

Provide case-insensitive completion #405

Merged

Conversation

renkun-ken
Copy link
Member

@renkun-ken renkun-ken commented Mar 30, 2021

Closes #401.

This PR uses grep(ignore.case=TRUE) to provide case-insensitive and partial matching completion items to replace the current case-sensitive, exact-matching-from-start filtering.

  • Change matching
  • Update test cases

@renkun-ken renkun-ken requested a review from randy3k March 30, 2021 10:21
@randy3k
Copy link
Member

randy3k commented Mar 30, 2021

It may be desired for the exact matches to show first. Though it may need some moderate refactoring.

@renkun-ken
Copy link
Member Author

It may be desired for the exact matches to show first. Though it may need some moderate refactoring.

I don't know how other editors handle the order, vscode already does it by choosing the exact match first.

@renkun-ken
Copy link
Member Author

image

The matches are case-insensitive. The first few are matches from the start, then some matches not from the start, then some fuzzy matches (these exist because the completion list is computed on G).

If the completion list is computed from GLM, then it looks like

image

@randy3k
Copy link
Member

randy3k commented Mar 30, 2021

How about the following situation?

Abc <- 1
aBc <- 2

What do Ab and aB trigger?

@renkun-ken
Copy link
Member Author

image

image

@randy3k
Copy link
Member

randy3k commented Mar 31, 2021

Thank you for working on it. Didn't have the time to test it. By the way, am I correct that for

abc <- 1
bca <- 1

ab will trigger both abc and bca?

@renkun-ken
Copy link
Member Author

renkun-ken commented Mar 31, 2021

ab will trigger both abc and bca?

Currently, no. I only switch from startWith(x, token) to grepl(token, x, ignore.case = TRUE). The completions are case-insensitive and should include the token (not necessarily from the start). For example,

abc <- 1
cab <- 2

Ab should return both abc and cab, but Ca should only return cab.

Given the returned completion items, it is then up to the editor to determine how to present these items.

@randy3k
Copy link
Member

randy3k commented Mar 31, 2021

I am a bit confused why for example as.table is there when ab is typed. The a the b in as.table are not consecutive.

Perhaps it was because the list was generated by the server when a was typed. And when b was typed, VSCode does not query the server and ,in order to speed up things, only do simple filtering?

@renkun-ken
Copy link
Member Author

renkun-ken commented Mar 31, 2021

When a is pressed, the completion request is sent, and it got all results that contain a or A, and isIncomplete = false. Then the following typing does not trigger completion request and then vscode does the filtering and sorting according to the token under cursor.

/**
  * This list it not complete. Further typing should result in recomputing
  * this list.
  */
  isIncomplete: boolean;

If the token at cursor is already ab and then c is pressed, then a completion request is sent with token abc, and we only get results that case-insensitively contains abc.

@randy3k
Copy link
Member

randy3k commented Mar 31, 2021

Thank you for the explanation. Totally forgot this setting. It makes total sense.

@renkun-ken renkun-ken merged commit 7edf19c into REditorSupport:master Mar 31, 2021
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.

Case-insensitive and fuzzy match in completion
2 participants