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

fix: don't error on files containing special chars #75

Merged
merged 2 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions autoload/suda.vim
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function! suda#read(expr, ...) abort range
\ '%sread %s %s',
\ options.range,
\ options.cmdarg,
\ path,
\ fnameescape(path),
\)), '^\r\?\n', '', '')
endif

Expand All @@ -82,7 +82,7 @@ function! suda#read(expr, ...) abort range
\ '%sread %s %s',
\ options.range,
\ options.cmdarg,
\ tempfile,
\ fnameescape(tempfile),
\))
" Rewrite message with a correct file name
let echo_message = substitute(
Expand Down Expand Up @@ -115,7 +115,7 @@ function! suda#write(expr, ...) abort range
\ options.range,
\ options.cmdbang ? '!' : '',
\ options.cmdarg,
\ tempfile,
\ fnameescape(tempfile),
\))
if has('win32')
" In MS Windows, tee.exe has been placed at $VIMRUNTIME and $VIMRUNTIME
Expand Down Expand Up @@ -261,7 +261,7 @@ function! suda#BufEnter() abort
let bufnr = str2nr(expand('<abuf>'))
execute printf(
\ 'keepalt keepjumps edit suda://%s',
\ fnamemodify(bufname, ':p'),
\ fnameescape(fnamemodify(bufname, ':p')),
\)
execute printf('silent! %dbwipeout', bufnr)
endfunction
Expand Down
4 changes: 2 additions & 2 deletions plugin/suda.vim
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ augroup END

function! s:read(args) abort
let args = empty(a:args) ? expand('%:p') : a:args
execute printf('edit suda://%s', args)
execute printf('edit suda://%s', fnameescape(args))
endfunction
command! -nargs=? -complete=file SudaRead call s:read(<q-args>)

function! s:write(args) abort
let args = empty(a:args) ? expand('%:p') : a:args
execute printf('write suda://%s', args)
execute printf('write suda://%s', fnameescape(args))
endfunction
command! -nargs=? -complete=file SudaWrite call s:write(<q-args>)