Permalink
Browse files

Merge branch 'more-rules-to-break-a-block'

* more-rules-to-break-a-block:
  Add rules for "{} break"
  Refine a cursor movement in the "() break" rule
  Change grouping for "() break"
  Refactor - Make "() break" test more readable
  Fix wrong keys to test "() break"

Close gh-3.
  • Loading branch information...
2 parents ab606eb + 743870f commit 547e467b96d08d671c0c35a8b50a60ea83f6daf9 @kana committed Mar 8, 2012
Showing with 13 additions and 7 deletions.
  1. +2 −5 autoload/smartpunc.vim
  2. +11 −2 t/api.vim
View
@@ -77,6 +77,7 @@ function! smartpunc#define_default_rules() "{{{2
\ {'at': '(\%#)', 'char': '<BS>', 'input': '<BS><Del>'},
\ {'at': '()\%#', 'char': '<BS>', 'input': '<BS><BS>'},
\ {'at': '\\\%#', 'char': '(', 'input': '('},
+ \ {'at': '(\%#)', 'char': '<Enter>', 'input': '<Enter>X<Enter>)<BS><Up><End><BS>'},
\ ])
call urules.add('[]', [
\ {'at': '\%#', 'char': '[', 'input': '[]<Left>'},
@@ -91,6 +92,7 @@ function! smartpunc#define_default_rules() "{{{2
\ {'at': '{\%#}', 'char': '<BS>', 'input': '<BS><Del>'},
\ {'at': '{}\%#', 'char': '<BS>', 'input': '<BS><BS>'},
\ {'at': '\\\%#', 'char': '{', 'input': '{'},
+ \ {'at': '{\%#}', 'char': '<Enter>', 'input': '<Enter>X<Enter><Up><End><C-t><BS>'},
\ ])
call urules.add('''''', [
\ {'at': '\%#', 'char': '''', 'input': '''''<Left>'},
@@ -121,10 +123,6 @@ function! smartpunc#define_default_rules() "{{{2
\ {'at': '\%#', 'char': '''', 'input': '''''<Left>',
\ 'syntax': ['Constant']},
\ ])
- " FIXME: Add more rules like '(<Enter>)'
- call urules.add('(<Enter>)', [
- \ {'at': '(\%#)', 'char': '<Enter>', 'input': '<Enter>X<Enter>)<BS><Up><C-o>$<BS>'},
- \ ])
"}}}
" ft_urule_sets_table... "{{{
@@ -137,7 +135,6 @@ function! smartpunc#define_default_rules() "{{{2
\ urules.table['""'],
\ urules.table['``'],
\ urules.table['English'],
- \ urules.table['(<Enter>)'],
\ ],
\ 'lisp': [
\ urules.table['Lisp quote'],
View
@@ -857,13 +857,22 @@ describe 'The default configuration'
setlocal expandtab
Expect &l:filetype ==# 'c'
- for key in ["\<Enter>", "\<Return>", "\<C-m>", "\<CR>", "\<C-j>", "\<C-j>"]
- execute 'normal' printf('ggcGfoo(%sbar,%sbaz', key, key)
+ for key in ["\<Enter>", "\<Return>", "\<CR>", "\<C-m>", "\<NL>", "\<C-j>"]
+ % delete _
+ execute 'normal' printf('ifoo(%sbar,%sbaz', key, key)
Expect getline(1, line('$')) ==# ['foo(',
\ ' bar,',
\ ' baz',
\ ' )']
Expect [line('.'), col('.')] ==# [3, 20 - 1]
+
+ % delete _
+ execute 'normal' printf('i{%sfoo();%sbar();', key, key)
+ Expect getline(1, line('$')) ==# ['{',
+ \ ' foo();',
+ \ ' bar();',
+ \ '}']
+ Expect [line('.'), col('.')] ==# [3, 15 - 1]
endfor
end
end

0 comments on commit 547e467

Please sign in to comment.