Browse files

Merge branch 'keep-register-contents'

Close gh-53.
  • Loading branch information...
2 parents 4dd4d66 + 134bedc commit 78ab4b3df24fa2753d3dfc1be75ed5a3df1565b8 @kana committed Apr 17, 2012
Showing with 28 additions and 2 deletions.
  1. +2 −2 autoload/smartinput.vim
  2. +26 −0 t/api.vim
View
4 autoload/smartinput.vim
@@ -77,7 +77,7 @@ function! smartinput#define_default_rules() "{{{2
\ {'at': '(\%#)', 'char': '<BS>', 'input': '<BS><Del>'},
\ {'at': '()\%#', 'char': '<BS>', 'input': '<BS><BS>'},
\ {'at': '\\\%#', 'char': '(', 'input': '('},
- \ {'at': '(\%#)', 'char': '<Enter>', 'input': '<Enter><Enter><Up><Esc>S'},
+ \ {'at': '(\%#)', 'char': '<Enter>', 'input': '<Enter><Enter><Up><Esc>"_S'},
\ ])
call urules.add('[]', [
\ {'at': '\%#', 'char': '[', 'input': '[]<Left>'},
@@ -92,7 +92,7 @@ function! smartinput#define_default_rules() "{{{2
\ {'at': '{\%#}', 'char': '<BS>', 'input': '<BS><Del>'},
\ {'at': '{}\%#', 'char': '<BS>', 'input': '<BS><BS>'},
\ {'at': '\\\%#', 'char': '{', 'input': '{'},
- \ {'at': '{\%#}', 'char': '<Enter>', 'input': '<Enter><Enter><Up><Esc>S'},
+ \ {'at': '{\%#}', 'char': '<Enter>', 'input': '<Enter><Enter><Up><Esc>"_S'},
\ ])
call urules.add('''''', [
\ {'at': '\%#', 'char': '''', 'input': '''''<Left>'},
View
26 t/api.vim
@@ -1206,4 +1206,30 @@ describe 'The default configuration'
" or ['(', '/o', '', ')foo'] if Insert mode is nested.
Expect [line('.'), col('.')] ==# [3, 3]
end
+
+ it 'should keep register contents'
+ % delete _
+ let @" = 'foo'
+ execute 'normal' "i{\<Return>"
+ Expect getline(1, '$') ==# [
+ \ '{',
+ \ '',
+ \ '}',
+ \ ]
+ Expect [line('.'), col('.')] ==# [2, 0 + 1]
+ Expect @" ==# 'foo'
+ Expect @0 ==# 'foo'
+
+ % delete _
+ let @" = 'foo'
+ execute 'normal' "i(\<Return>"
+ Expect getline(1, '$') ==# [
+ \ '(',
+ \ '',
+ \ ')',
+ \ ]
+ Expect [line('.'), col('.')] ==# [2, 0 + 1]
+ Expect @" ==# 'foo'
+ Expect @0 ==# 'foo'
+ end
end

0 comments on commit 78ab4b3

Please sign in to comment.