Closed aarondill closed 5 months ago
autoload/suda.vim: The suda#BufEnter()
function has been updated to use fnameescape()
for better file name handling.
suda cannot handle files that include '#' in the name
suda seems to be unable to handle files with '#' in the name.
I am able to reproduce this with a very minimal config, e.g.
call plug#begin('~/.local/share/nvim/plugged') Plug 'lambdalisue/suda.vim' call plug#end()
$ touch '#test'
$ nvim '#test'
When I open the file:
Error detected while processing BufEnter Autocommands for "*"..function suda#BufEnter: line 29: E194: No alternate file name to substitute for '#': keepalt keepjumps edit suda:///home/user/#test
on :SudaWrite
:
Error detected while processing function
Interestingly, if I call the file '##test', the write succeeds, but a file named '##testtest' is written.
Using nvim v0.9.4. Please let me know if I can provide any more information.
The updates to suda.vim
enhance the plugin's capability to handle file names with special characters like #
. By employing fnameescape()
in the relevant functions, the plugin now ensures that file paths are correctly processed, thus mitigating errors related to file name interpretation in Vim.
File Path | Change Summary |
---|---|
autoload/suda.vim |
Updated suda#BufEnter() to use fnameescape() for file name handling. |
Objective | Addressed | Explanation |
---|---|---|
Handle files with # in the name (#66) |
✅ |
A hop, a skip, in the code we dive, 🐰
Fixing bugs, making plugins thrive.
Special chars in names, no more a strife,
suda.vim
now handles them, oh what a life!
Cheers to paths, now tamed and neat,
Withfnameescape
, no defeat! 🌟
@sserenade can you test this to ensure it works for your usecase(s)?
Testing this by loading the branch in the config, with a similar test as before:
Plug 'aarondill/suda.vim',{'branch':'fix-other-file'}
$ echo 'foo' > '#test'
$ cat '#test'
foo
# chown root:root '#test'
$ nvim '#test'
On open, I get the below error and the file contents aren't loaded, though vim still thinks I'm editing a file called '#test':
[suda] Vim(read):E194: No alternate file name to substitute for '#'
I'm able to write to the file and save it, with the correct name, with no errors:
bar
:wq
$ cat '#test'
bar
However, opening the file with vim after saving it makes the above error appear again, and the file is not loaded.
I think I know where this issue is. i'll work on fixing it soon
@sserenade can you try with the latest commit?
With the latest commit, suda now behaves as expected and appears to be able to handle the file. I get no errors upon reading or writing, the file contents are what I expect, and the filename appears correct after writing.
Thank you for your work on this!
@lambdalisue any thoughts on this before merging it?
fixes: #66
Summary by CodeRabbit