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

Code completion sometimes overwrites existing text #30

Closed
krassowski opened this issue Sep 10, 2019 · 7 comments
Closed

Code completion sometimes overwrites existing text #30

krassowski opened this issue Sep 10, 2019 · 7 comments
Labels
bug Something isn't working feature:completion
Milestone

Comments

@krassowski
Copy link
Member

krassowski commented Sep 10, 2019

Happens only when completing a code symbol which is in the middle of a line (not at the end). Needs unit tests to prevent this in the future.

Example:
DataFrame(da<tab>) leads to DataFrame(dta=), should DataFrame(data=)

R examples:
data.frame(row.nam<tab>data.frame(row.nrow.names
data.f<tab>data.fdata.frame

@krassowski krassowski added the bug Something isn't working label Sep 10, 2019
@krassowski krassowski added this to the 0.6 milestone Oct 5, 2019
@krassowski
Copy link
Member Author

Minimal Python example without the need to import anything:

CamelCase = 1
mean(cam<tab>

@krassowski
Copy link
Member Author

Another test case: from jupyter_helpers.tabl<tab>

@krassowski
Copy link
Member Author

krassowski commented Jan 12, 2020

def display_table():
    pass

disp<tab>data

leads to
ddisplay_table<cursor>
should be:
display_table<cursor>data

@yunair
Copy link
Contributor

yunair commented Jan 14, 2020

I don't think this is a valid test case

def display_table():
    pass

disp<tab>data

Python doesn't support to write code like this

@krassowski
Copy link
Member Author

Some explanations: I use <tab> to indicate invocation of the completer with tab key and <cursor> to indicate the expected position of cursor (thus the code is valid).

@krassowski
Copy link
Member Author

krassowski commented Jan 19, 2020

The from jupyter_helpers.tabl<tab> can be reproduced in bare Python with:

from os.pat<tab> → choose path or os.path; the result expected for both is from os.path, but the latter produces os.os.path. This is because the kernel returns prefixed tokens (with os.), while LSP (pyls) does not (and we can handle either prefixed responses or non-prefixed responses, but not both mixed together, due to how the completer in JupyterLab is written).

  • we cannot detect the prefix from kernel response alone
  • we have to take a look at the token preceding the requested token to infer the prefix, but then the completions with repeats may be affected..
  • or, we could strip the prefix from kernel responses - and this is what is already present in the merge step - apparently does not always work...

@krassowski
Copy link
Member Author

krassowski commented Jan 19, 2020

Even more nicer test case from os.pathse<tab>from os.pathsep. This one had false negatives. Need to have one with pyls completion; from os.pat<tab> → select pathsepfrom os.pathsep will work.

I now got fixes for every case reported so far, will PR soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feature:completion
Projects
None yet
Development

No branches or pull requests

2 participants