-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Fixes #8483 Windows completion error #8693
Conversation
This seems to work fairly well in shell mode, as long as I use forward slashes for everything. If I use double-backslashes at all, the completions do the wrong thing: And in Since you've been looking into this section of code, I'd quite appreciate attempts to make this behave more consistently. Would also be good to add more tests for Windows behavior in Also it's a good idea in the future to make proposed changes in a new branch for each new PR, so you can have multiple independent PR's open at the same time, and track changes to master if necessary. |
Unfortunately, I can't test julia on windows for now. Maybe we should just replace joinpath here by manual joining/appending with a forward-slash? It sounds like backslash is a world of problems for windows users. Of course, the better alternative would be to fix that weird behavior with backslashes, but I can't help with that. |
Thank you for the tips @tkelman. This example don't work in 0.4 before my patch Do you guy's have any idea of what is going on with broke |
Unfortunately I don't, by now I'm sure you know more about the REPL code than I do (don't think I've ever touched those files or studied them in detail). There might be some heuristic for completion somewhere for when something is "path-like," but I wouldn't know exactly where to find it. It sounds like there's a fair bit of conflation somewhere in the code between the meaning of |
I have been working a bit more and it seems that the reason to the weird behavior of @tkelman it could be nice the precompilation trick to be documented somewhere to make it easier for windows people to get started developing. Can you just delete sys.ji to run without precompilation? |
That sounds promising!
Yeah this is true, I should probably copy-paste various instructions I've written down on the google group or issue comments and put them into
Not as far as I know, I'm not sure whether a JIT-everything, precompile-nothing mode would be practical or possible. |
It would be painfully slow to start up, since you'd have to run through everything necessary to build sys.ji every startup, including all the bootstrapping. Easier to rebuild the system image on demand. |
Hi I have been working a bit more on solving the problem. It now autocompletes with |
The space-in-path problem is also present on linux and is worth opening a separate issue imo. The auto-complete probably should either escape the space or surround the path with double-quotes. But the auto-complete also fails to complete correctly-escaped paths like As for your patch, you should probably add (windows-only) tests to I don't have any idea about the |
To my knowledge the reason why it does not complete correctly is in the |
So on windows Eventually we'll be getting rid of that command-line git and replacing it with libgit2 for the package manager. What to do about common utilities like |
Can we then close this? It should be backported to 0.3. |
It's a problem in both master and |
Yes, it is. I do not think I can do it better right now and it is in a better condition than it is in 0.3-0.4. |
I'll do some testing of these changes and let you know how I like it, and let others review it as well. The Travis failures on Mac are unrelated, they're due to @staticfloat bumping the openblas formula to v0.2.12, but he hasn't built a bottle (binary) yet. Edit: and I think the Arpack and SuiteSparse Homebrew bottles might now need to be rebuilt to account for the different openblas library version? |
@dhoegh ok shell mode completion is now working quite well, except for paths with spaces (that can be a separate issue as @lucasb-eyer said). But |
I have fixed |
Great! This works very nicely, I'm in favor of merging this as soon as someone else gives the okay on the deletion in dhoegh@d574f03. The Travis failure on Mac was unrelated, a problem with arpack due to the openblas bump in homebrew-julia. |
Hi @tkelman |
I can reproduce that either with or without your change, so I think it's unrelated. It only appears to happen if I haven't run
This looks similar to the error that used to cause |
…re `Pkg.init()` fails
error("dangling backslash") | ||
end | ||
update_arg(s[i:j-1]); i = k | ||
c, k = next(s,k) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dhoegh, can you explain what the purpose of this part of the change is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the string ends on \\
it give an error even though cd C:\\
is valid on windows:
julia> Base.shell_parse("cd C:\\",true)
ERROR: dangling backslash
in shell_parse at string.jl:1146
And if string ends on cd C:\\P
is parsed then it splits the dir path and this makes the complete_path
complete on only "P"
instead of the path.
julia> Base.shell_parse("cd C:\\P",true)
(:((("cd",),("C:","P"))),0:-1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like the wrong place to fix this – a dangling backslash in a shell-quoted expression is still an error. In C:\\
the backslash is already "quoted" by the first backslash. I may be missing something here though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It gets escaped before the function sees it though:
julia> for c in "C:\\"; println(c); end
C
:
\
so it looks like a dangling backslash to the shell_parse
function. We could instead leave in this section of code but skip it on Windows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since 47d3ecf the auto completion is completing with a ``` in shell>
and if `\` where used then the auto completion did not work. This pull changes it to always auto complete and use `\` in paths and fixes the completion behavior. As @tkelman mention this part could be skipped on windows. Else we should role `Base.REPLCompletions.shell_completions` back to before 47d3ecf and use `/` as path separator again in shell mode on windows.
@tkelman, @StefanKarpinski I have fixed the problem regarding |
Ah, this seems much less scary. I'd still like to understand this a little better, but it seems ok at a glance. |
The reason why it works is in how the shell_parse returns an expression of tuples for example:
where we would like the path at
|
@@ -253,9 +254,10 @@ function shell_completions(string, pos) | |||
# Now look at the last thing we parsed | |||
isempty(args.args[end].args) && return UTF8String[], 0:-1, false | |||
arg = args.args[end].args[end] | |||
if isa(arg,String) | |||
if isexpr(args.args[end],:tuple) && all(map(s->isa(s,String),args.args[end].args)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think isexpr(args.args[end],:tuple) &&
could be removed since shell_parse() always returns a tuple.
Git isssue I am fixing them plus a squash. |
Ok sound good. The point is in how the julia> Base.shell_parse("cd -l ..\\\\test\\\\do", true)
(:((("cd",),("-l",),("..","\\test","\\do"))),0:-1)
julia> Base.shell_parse("cd -l ../test/do", true)
(:((("cd",),("-l",),("../test/do",))),0:-1) It will group the path like above and hence should not effect the path on unix. This grouping is what I am thinking of taking advantage of when making the paths work with spaces, it would be look like this: julia> Base.shell_parse("cd -l ../test/do\\ te", true)
(:((("cd",),("-l",),("../test/do"," te"))),0:-1) Hence you will actually get the right path sent to "complete_path" when this is joined. This also means that you with this pull request could do:
And I plan to fix this behavior in a second pull request. |
Hi, is there a plan for review/anyone having any objections? @tkelman, @lucasb-eyer, I have made a fix for the space completion thing in commit 7e1f33a. Im happy with how it is turned out to get it in shell mode, which is five lines of code and I am quite happy with how it works. However, I do not know if I think it belongs in the julia mode like:
Where the backslash seems wrong. It's also account for all changes from line 151-203. I would appreciate if any of you could try it. I am going to file a pull request on it when this one is merged. |
@dhoegh I would love if someone else who's qualified can look at this. I have no control over others' time to do so though. Why is the backslash wrong in Julia mode? If what we're completing on is a file/folder name, then backslash-space is the way bash in cygwin or msys2 completes paths, being consistent works for me. Can you come up with a functioning version of the spaces-in-paths patch that doesn't change any of the same lines as this one? It seems mostly independent, and you could open a new independent PR for review maybe before this one gets merged. If this gets merged before the new one does, you can rebase the new one to include any changes to the same lines of code. |
Maybe it's just me, I would love to get a pr going so the solution could be discussed, but I need two lines from this one. |
Which two lines? The only overlap I see in 7e1f33a is the deletion of |
The 257 and 259. |
Else it's not going to work. |
Oh damn, gotcha. Exactly the parts I'm not sure about. |
Yeah I know we should probably ping some who have a understanding of the shell_parse function. |
@@ -147,7 +148,7 @@ end | |||
include("latex_symbols.jl") | |||
|
|||
const non_identifier_chars = [" \t\n\r\"\\'`\$><=:;|&{}()[],+-*/?%^~"...] | |||
const non_filename_chars = [" \t\n\r\"\\'`@\$><=;|&{("...] | |||
const non_filename_chars = [(" \t\n\r\"'`@\$><=;|&{(" * (@unix?"\\" : "")) ...] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I'd say completely remove \\
because on linux I can create a file or directory named lol\hi
, I just tried it: touch lol\\hi && ls
. Or is there any other repercussion I'm missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no objection in removing it. Lucas could you try and give 257 and 259 a look and see if you can think/find any undesireable behivor on Linux caused by these lines? These two lines is also needed to get spaces in paths working on windows and Linux.
re 257 and 259: As I understand it, I think
A little (I don't currently have the time to work on a patch, unfortunately.) Edit: I did give this PR a quick try and didn't find any obvious problems, but I don't know this code any better than you. |
@lucasb-eyer, when you enter julia> Base.shell_parse("ls folder\\ with\\ spaces")
(:((("ls",),("folder"," with"," spaces"))),0:-1) Which is correctly grouped and it just needs to be joined as I do in 259. julia> Base.shell_parse("cd ..\\\\test\\\\dow", true)
(:((("cd",),("..","\\test","\\dow"))),0:-1) So i think the julia> Base.shell_parse("ls folder\ with\ spaces")
(:((("ls",),("folder",),("with",),("spaces",))),0:-1) I would end up joining |
Right, I missed double-escaping it. I don't see anything else then, though I'm not an expert. |
@lucasb-eyer thank you for your time. |
I'm tempted to just click merge on this and see whether anything breaks / anyone cares. |
Yeah, go for it. |
Fixes #8483 Windows completion error
Yay, thanks. Hope you had a good flight. |
@JuliaBackports if this doesn't cause any problems over the next week or so |
This should fix #8483 I am not a Julia power user yet so could some of you guy's check it's working because I have not compiled base with it, @lucasb-eyer, @tkelman?