Skip to content

Commit

Permalink
fix: literal newline "\n" escape
Browse files Browse the repository at this point in the history
related to ruby-formatter#28

The echo command treats "\n" from selection as non-literal string, which
causes one-line string like "hello\nworld" becoming two lines. Using
`printf %s` preserves it as one line.
  • Loading branch information
zhengpd committed Dec 31, 2020
1 parent ba7d1dd commit 0fa604c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion autoload/rufo.vim
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function! s:format(start_line, end_line) abort
endif

let l:selection = join(getline(a:start_line, a:end_line), "\n")
let l:out = systemlist('echo ' . shellescape(l:selection) . '| rufo')
let l:out = systemlist('printf %s ' . shellescape(l:selection) . '| rufo')
return [s:formatting_failed(v:shell_error), l:out]
endf

Expand Down

0 comments on commit 0fa604c

Please sign in to comment.