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

Improves detection of whether tab-completion is in a string and suppresses Jedi #12128

Merged
merged 1 commit into from Feb 28, 2020
Merged

Conversation

ecoon
Copy link
Contributor

@ecoon ecoon commented Feb 13, 2020

Refs #10926 and #11530

Jedi results swamp file_matches and dict_key_matches in
tab-completion, which is a real nuisance. The logic in the jedi
completor tried to catch cases where it was "in a string", but that
logic only looked at the last child in the current token, which was a little fragile,
breaking in lots of cases such as:

'./<tab>
"mypath/<tab>

etc.

This seems a bit more robust in that it searchs for the first character in
the current parser tree and checks if its value starts with ' or ".

This detection of "in a string" then turns off jedi and returns some
sanity to the set of matches.

Note I have developed this with jedi 0.13.2 -- not sure if it is different logic in older versions.

…sses Jedi.

Refs #10926 and #11530

Jedi results swamp file_matches and dict_key_matches in
tab-completion, which is a real nuisance.  The logic in the jedi
completor tried to catch cases where it was "in a string", but that
logic only looked at the previous character, and was a little fragile,
breaking in lots of cases such as:

'./<tab>
"mypath/<tab>

etc.

This seems a bit more robust in that it searchs for the first token in
the current parser tree and checks if its value starts with ' or ".

This detection of "in a string" then turns of jedi and returns some
sanity to the set of matches.
@Carreau
Copy link
Member

@Carreau Carreau commented Feb 27, 2020

That would be nice ! Could it even be something that could be upstreamed in Jedi, so we coudl teach jedi to say "I'm in a string" ? or even complete strings ?

I want o merge a PR that touch many files first and then I'm likely to get that merge. Likely tomorrow. Thanks for your patience and contributions !

@Carreau
Copy link
Member

@Carreau Carreau commented Feb 27, 2020

Side note your commit is attached to your Oak Ridge mail, but github is not aware that you have an Oak Ridge email, sothe contribution will not appear to your profile.

Do you ant to :

  1. merge as is
  2. edit AUthors
  3. go into github setting and teach it about your oakridge email ?

@Carreau Carreau added this to the 7.13 milestone Feb 27, 2020
@ecoon
Copy link
Contributor Author

@ecoon ecoon commented Feb 28, 2020

Thanks, I updated my github profile.

@ecoon
Copy link
Contributor Author

@ecoon ecoon commented Feb 28, 2020

That would be nice ! Could it even be something that could be upstreamed in Jedi, so we coudl teach jedi to say "I'm in a string" ? or even complete strings ?

I believe so. The code checking "I'm in a string" is entirely based on jedi's parsing. I'm not sure what is there in jedi to complete strings -- most of the time useful string completions would be either filenames or keys in a container, so I'm not sure what is/could be added to jedi with regard to that.

Also, if I get time, I'll look at the implementation for "keys in a dict." Ideally this would be anything that implements keys(), or maybe even anything that implements contains, not just dict -- I've noticed that other file objects such as hdf5/netcdf4 files, which implement the keys() method and mimic a dictionary to work within their file structure don't work with tab completion.

@Carreau
Copy link
Member

@Carreau Carreau commented Feb 28, 2020

I believe so. The code checking "I'm in a string" is entirely based on jedi's parsing. I'm not sure what is there in jedi to complete strings -- most of the time useful string completions would be either filenames or keys in a container, so I'm not sure what is/could be added to jedi with regard to that.

I'm mostly wondering if we could add completions plugin to jedi instead of hacking around jedi.

For single-line string I agree, but if we are in a docstring, jedi might be able to help by completing also to the parameter of given functions or similar.

@Carreau Carreau merged commit 2308f55 into ipython:master Feb 28, 2020
2 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/ipython that referenced this issue Feb 28, 2020
@Carreau
Copy link
Member

@Carreau Carreau commented Feb 28, 2020

Thanks, I updated my github profile.

Good, merging.

Carreau added a commit that referenced this issue Feb 28, 2020
…128-on-7.x

Backport PR #12128 on branch 7.x (Improves detection of whether tab-completion is in a string and suppresses Jedi)
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.

None yet

2 participants