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

Add REPL completion for tilde paths #23475

Merged
merged 4 commits into from
Sep 5, 2017
Merged

Add REPL completion for tilde paths #23475

merged 4 commits into from
Sep 5, 2017

Conversation

HarrisonGrodin
Copy link
Contributor

Autocompletes tilde expansion (using expanduser) in REPL strings and commands.

Overrides path completions if a user expansion is available. For example, ~/Docu will autocomplete to /home/user/Docu after one <TAB>, and then to /home/user/Documents after a second <TAB>.

Closes #22599.

Overrides path completions if a user expansion is available. For
example, `~/Docu` will autocomplete to `/home/user/Docu` after one
<TAB>, and then to `/home/user/Documents` after a second <TAB>.
@KristofferC KristofferC added the needs tests Unit tests are required for this change label Aug 27, 2017
@KristofferC
Copy link
Sponsor Member

Thanks for the PR. I personally think this makes sense but other will have to chime in as well. It would be great to have a few tests for the functionality. There is a corresponding file replcompletions.jl where tests for this should be suitable.

@ararslan ararslan added domain:filesystem Underlying file system and functions that use it stdlib:REPL Julia's REPL (Read Eval Print Loop) labels Aug 27, 2017
@fredrikekre fredrikekre removed the needs tests Unit tests are required for this change label Aug 27, 2017
@HarrisonGrodin
Copy link
Contributor Author

It seems that the OSX Travis build has been terminated because the "log length has exceeded the limit of 4 MB". Is that due to a change I made, or is it just an issue with OSX builds in general?

@KristofferC
Copy link
Sponsor Member

KristofferC commented Aug 29, 2017

Seems to be an issue with the build system spitting out a lot of output? Should not be related to this PR.

@@ -462,13 +467,19 @@ function completions(string, pos)
m = match(r"[\t\n\r\"><=*?|]| (?!\\)", reverse(partial))
startpos = nextind(partial, reverseind(partial, m.offset))
r = startpos:pos

expanded = complete_expanduser(replace(string[r], r"\\ ", " "), startpos:pos)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can pass r as the last argument?

@rfourquet
Copy link
Member

Is there a case where it's useful to expand "~" but not what comes next? i.e. in your example, why not expand "~/Docu" directly into "/home/user/Documents" in one shot ? FWIW, ipython does that.

@HarrisonGrodin
Copy link
Contributor Author

@rfourquet Requiring two separate <TAB> presses seems to give more control to the user. Consider the case of creating a directory called ~/Docu:

julia> mkdir("~/Docu
julia> mkdir("/home/user/Docu
julia> mkdir("/home/user/Docu")

This is applicable in the case of file creation, as well. For example, the user may want to create /home/user/julep.md when /home/user/julia/ already exists; completing ~/jul to /home/user/julia/ seems like an undesired behavior.

@rfourquet
Copy link
Member

It seems like a desirable behavior, and it fixes an annoying issue. thanks @HarrisonGrodin !

@rfourquet rfourquet merged commit 4502ee4 into JuliaLang:master Sep 5, 2017
@HarrisonGrodin HarrisonGrodin deleted the feature/repl-complete-expanduser branch September 5, 2017 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:filesystem Underlying file system and functions that use it stdlib:REPL Julia's REPL (Read Eval Print Loop)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants