-
Notifications
You must be signed in to change notification settings - Fork 2
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
Jedi autocomplete mistakes path literals (p"foo"
) for strings
#1
Comments
The problem is that the jedi xontrib is not aware of any xonsh syntax, but treats the input as python code. |
Thank you for pointing me in the right direction! What you linked is for glob and regex literals like My original issue was about path literals like
I can maybe try this. Do you think this would this slow things down too much? I also noticed that the code for builtins has no type annotations. This is likely to make Jedi autocomplete much harder even if we do AST expansion. I see that the Annotating Based on my tests, the best way to "type" this function looks like returning However Jedi ambiguity is still better than the current situation where |
I don't think this would be a problem, especially as this is only about single lines in interactive use. Also, the delay caused by jedi itself can easily be an order of magnitude higher. The bigger problem I think is that we can only parse syntactically correct (i.e. usually only finished) lines, and that we need column information for jedi that will be hard to track if the line gets transformed like this. So maybe it would be better to invoke the lexer like this from xonsh.lexer import Lexer
lexer = Lexer()
lexer.input(src)
tokens = list(lexer) to identify path literal tokens (and others like This does not need to be completely right (i.e. the arguments passed to the builtin should be irrelevant for autocompletion).
Type annotations could certainly be added, xonsh uses them at many places but not everywhere yet.
Should this mechanism work, I think we could think about factoring this into multiple functions to enable precise type annotations. |
@Techcable are you working on this or should I give it a try? |
Feel free to give it a try! I haven't even started yet :) |
xonfig
Expected Behavior
p".".<TAB>
should autocomplete as if it was apathlib.Path
, not astr
Current Behavior
I am using Jedi version 0.18.1 (if that makes any difference).
I would be happy to work on a fix if you can point me in the right direction :)
Steps to Reproduce
Install
jedi
xontribJust do
p"~/Documents".<TAB>
and it will autocomplete like a string instead of a PathFor community
⬇️ Please click the 👍 reaction instead of leaving a
+1
or 👍 commentThe text was updated successfully, but these errors were encountered: