-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
suda#read throws uncaught exception when opening suda:///not-existing.txt #18
Comments
It sounds really complicated 🤕 Well in the usual case, I think we can use What I'm not sure is the situation when a user does not have permission to read the parent directory. I'm not sure if Anyway, I agree to NOT silence the error. We need deep investigation before applying fixes. |
It returns an empty string in this case. I've been thinking about the UX of the 'wrong password' vs 'other legitimate reasons for the buffer to appear empty' and I've had an idea: When a In case the parent directory of the requested file doesn't exist, suda should still suggest to read the file with Perhaps this kind of behavior is overwhelming but I think it'll be most liable. |
I think there are following two distinct issues
So I'd love to
|
Oh right, I guess it'll be better to fix this in steps but there are a few details I think that should be discussed as for the implementation, per issue:
|
Hey,
I noticed that if I launch
nvim suda:///not-existing.txt
and/not-existing.txt
doesn't exist, I get an exception:Here's where this happens, for reference:
https://github.com/lambdalisue/suda.vim/blob/b867074b30f623ccb81a0bb8d1b74a6d0fafd160/autoload/suda.vim#L70-L77
cat
fails because the file doesn't exist. Technically this error is harmless because if the file doesn't exist the buffer should be empty anyway. Perhaps this 'bug' shouldn't even be fixed?We could ignore any errors but that won't be reliable if e.g the password was incorrect. As I'm thinking about it, this part of suda should be implemented with extreme care because if no error is thrown, a user might think he opened an empty file, add something according to some manual, save it (without errors) and end up with a totally different file with all the previous content lost.
According to my tests, even a wrong password ends up with an empty buffer and the same exception error is printed. Maybe suda should clearly state to the user what command failed and that the buffer's contents don't correspond to the real contents? Unless of course the file doesn't exist.. Anyway, I wonder what is your opinion on the subject.
Thanks.
The text was updated successfully, but these errors were encountered: