-
Notifications
You must be signed in to change notification settings - Fork 72
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 support for ~
and ..
during file completion
#76
Add support for ~
and ..
during file completion
#76
Conversation
Codecov Report
@@ Coverage Diff @@
## master #76 +/- ##
==========================================
- Coverage 89.93% 85.77% -4.16%
==========================================
Files 14 15 +1
Lines 864 963 +99
==========================================
+ Hits 777 826 +49
- Misses 77 118 +41
- Partials 10 19 +9
Continue to review full report at Codecov.
|
@posener Please review |
39758bc
to
3bd6a30
Compare
3bd6a30
to
7917859
Compare
~
during file completion~
and ..
during file completion
@posener Please review Cc: @kadel @metacosm @mik-dass |
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.
Hi,
Thanks for the PR :-)
It looks to me like this change spread on too many places than it should have.
I think that adding the resolveHomeDir
function to the fixPathForm
will suffice - as it is no difference than absolute path completion.
Also, if you could please add tests.
Thanks!
utils.go
Outdated
@@ -37,6 +51,15 @@ func fixPathForm(last string, file string) string { | |||
return fixDirPath(rel) | |||
} | |||
|
|||
func resolveHomeSymbol(path string) string { |
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.
Can you use https://github.com/mitchellh/go-homedir instead?
It looks like there is a bit more code there, so it might cover more cases for more OSs.
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.
Sure @posener
predict_files.go
Outdated
if strings.HasSuffix(a.Last, "/..") { | ||
return nil | ||
} | ||
/* |
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.
Why is this code commented out?
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 am not sure why this shouldn't be there?
Its totally legal in my opinion for linux paths to end with /..
But for some reason(I assume bcoz listfiles doesn't list .
and ..
), that this doesn't work here and so its better we know that a trailing or in b/w usage of /..
doesn't work
So, I'll undo the change here
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.
We can probably revisit it after this PR 😉
return strings.Replace(path, usr.HomeDir, "~", 1) | ||
} | ||
|
||
if strings.Contains(last, "..") { |
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.
The ../
completion on my machine works fine.
I think that the problem is that you tried to complete after ..
and not after ../
.
If not, can you elaborate which terminal and OS are you using?
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.
@posener It doesn't seem to work for me(without this PR) on
[redhat@localhost odo]$ echo $SHELL
/bin/bash
[redhat@localhost odo]$ bash --version
GNU bash, version 4.4.12(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
[redhat@localhost odo]$ cat /etc/*-release
Fedora release 27 (Twenty Seven)
NAME=Fedora
VERSION="27 (Workstation Edition)"
ID=fedora
VERSION_ID=27
PRETTY_NAME="Fedora 27 (Workstation Edition)"
ANSI_COLOR="0;34"
CPE_NAME="cpe:/o:fedoraproject:fedora:27"
HOME_URL="https://fedoraproject.org/"
SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=27
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=27
PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
VARIANT="Workstation Edition"
VARIANT_ID=workstation
Fedora release 27 (Twenty Seven)
Fedora release 27 (Twenty Seven)
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.
Not even after ../
Hi @posener
My pleasure :)
But the problem with
Sure... |
Signed-off-by: anmolbabu <[email protected]>
Signed-off-by: anmolbabu <[email protected]>
7917859
to
f2225fa
Compare
@posener Can you take a brief look if the new form of the PR looks good Note: The size of the PR has grown due to the committed vendor pkg(practice from my current project), For ease of review, I have broken the PR into multiple commits with the vendor going in a separate exclusive commit |
Signed-off-by: anmolbabu <[email protected]>
Signed-off-by: anmolbabu <[email protected]>
Signed-off-by: anmolbabu <[email protected]>
a6eeb79
to
290ce91
Compare
Signed-off-by: anmolbabu <[email protected]>
290ce91
to
0c3b234
Compare
@posener Ping |
I'm sorry, but this PR became too big.
|
I am using glide to pull over the
Quite some time now :) will revisit this again and check once but I see results of my previous experiments in #76 (comment) but will give this a retry... And now since I have broken the PR into 2 I think atleast #79 is unblocked for review |
This PR adds support for auto-completion of file paths starting
~
and..
whichtranslate to user home dir
Signed-off-by: anmolbabu [email protected]