Closed obcat closed 3 years ago
I'm not sure it's correct, but this patch seems to fix the issue:
diff --git a/autoload/operator/sandwich/stuff.vim b/autoload/operator/sandwich/stuff.vim
index 6ee0fe5..2c7e36b 100644
--- a/autoload/operator/sandwich/stuff.vim
+++ b/autoload/operator/sandwich/stuff.vim
@@ -339,9 +339,11 @@ function! s:check_textobj_diff(head, tail, candidate, opt_noremap) abort "{{{
endif
endfor
- " restore visualmode
- execute 'normal! ' . visualmode
- execute 'normal! ' . "\<Esc>"
+ if visualmode !=# ''
+ " restore visualmode
+ execute 'normal! ' . visualmode
+ execute 'normal! ' . "\<Esc>"
+ endif
" restore marks
call setpos("'<", visual_head)
call setpos("'>", visual_tail)
Ah! The patch might be wrong. Maybe we should restore the visualmode even when it was empty. I'll submit a revised version tomorrow (I'm already in the ohuton now)
Good morning. Here is a revised version:
diff --git a/autoload/operator/sandwich/stuff.vim b/autoload/operator/sandwich/stuff.vim
index 6ee0fe5..552b40d 100644
--- a/autoload/operator/sandwich/stuff.vim
+++ b/autoload/operator/sandwich/stuff.vim
@@ -340,8 +340,12 @@ function! s:check_textobj_diff(head, tail, candidate, opt_noremap) abort "{{{
endfor
" restore visualmode
- execute 'normal! ' . visualmode
- execute 'normal! ' . "\<Esc>"
+ if visualmode ==# ''
+ call visualmode(1)
+ else
+ execute 'normal! ' . visualmode
+ execute 'normal! ' . "\<Esc>"
+ endif
" restore marks
call setpos("'<", visual_head)
call setpos("'>", visual_tail)
Still, it may not correct. Just for your information...
Thanks!
Thanks too!
Explain the issue
Using
<Plug>(operator-sandwich-delete)
might give anUnanticipated error
.To Reproduce
Write this in
/tmp/vimrc
:Run
vim -Nu /tmp/vimrc
.Source this script:
Unanticipated error
is given:The buffer contains this text:
Expected behavior
No error is given. The buffer contains this text:
Environment