lambdalisue / vim-suda

🥪 An alternative sudo.vim for Vim and Neovim, limited support sudo in Windows
MIT License
713 stars 27 forks source link

suda cannot handle files that include '#' in the name #66

Closed sserenade closed 5 months ago

sserenade commented 11 months ago

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'
# chown root:root '#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 <SNR>8_write:                                                   
line    2:
E194: No alternate file name to substitute for '#': write suda:///home/user/#test

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.

lambdalisue commented 11 months ago

It sounds a bug for handling a bufname. We must escape # (and maybe %) prior to execute edit suda:///... command.