Skip to content

Commit

Permalink
Escape double quotes in new text for edits
Browse files Browse the repository at this point in the history
Fixes a bug where the `execute` would be ended by a double quote and the
next characters were treated as viml.
  • Loading branch information
natebosch committed Jul 7, 2018
1 parent fb455ee commit b5b2163
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Add support for passing a pattern to `:LSClientFindCodeActions`. When exactly
one action has a `title` that matches the pattern it will be run
automatically.
- Bug fix: Handle workspace edits that have double quotes.

# 0.3.0

Expand Down
5 changes: 3 additions & 2 deletions autoload/lsc/edit.vim
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ endfunction

" Find the command to apply a `TextEdit`.
function! s:Apply(edit) abort
let l:new_text = substitute(a:edit.newText, '"', '\\"', 'g')
if s:IsEmptyRange(a:edit.range)
if a:edit.range.start.character >= len(getline(a:edit.range.start.line + 1))
let l:insert = 'a'
Expand All @@ -147,7 +148,7 @@ function! s:Apply(edit) abort
\ a:edit.range.start.line + 1,
\ a:edit.range.start.character + 1,
\ l:insert,
\ a:edit.newText
\ l:new_text
\)
else
" `back` handles end-exclusive range
Expand All @@ -158,7 +159,7 @@ function! s:Apply(edit) abort
\ a:edit.range.end.line + 1,
\ a:edit.range.end.character + 1,
\ l:back,
\ a:edit.newText
\ l:new_text
\)
endif
endfunction
Expand Down

0 comments on commit b5b2163

Please sign in to comment.