Browse files

Merge branch 'more-rules-to-undo-inserting-a-block'

* more-rules-to-undo-inserting-a-block:
  Add a more rule to undo the last inserted ``
  Add a more rule to undo the last inserted ""
  Add a more rule to undo the last inserted ''
  Add a more rule to undo the last inserted {}
  Add a more rule to undo the last inserted []
  Add a more rule to undo the last inserted ()

Close gh-29.
  • Loading branch information...
2 parents fe1bb4e + 982cd85 commit ab606eb3db5b99ad97012ea9384ec8e122b78edf @kana committed Mar 7, 2012
Showing with 60 additions and 12 deletions.
  1. +6 −0 autoload/smartpunc.vim
  2. +54 −12 t/api.vim
View
6 autoload/smartpunc.vim
@@ -75,36 +75,42 @@ function! smartpunc#define_default_rules() "{{{2
\ {'at': '\%#', 'char': '(', 'input': '()<Left>'},
\ {'at': '\%#)', 'char': ')', 'input': '<Right>'},
\ {'at': '(\%#)', 'char': '<BS>', 'input': '<BS><Del>'},
+ \ {'at': '()\%#', 'char': '<BS>', 'input': '<BS><BS>'},
\ {'at': '\\\%#', 'char': '(', 'input': '('},
\ ])
call urules.add('[]', [
\ {'at': '\%#', 'char': '[', 'input': '[]<Left>'},
\ {'at': '\%#\]', 'char': ']', 'input': '<Right>'},
\ {'at': '\[\%#\]', 'char': '<BS>', 'input': '<BS><Del>'},
+ \ {'at': '\[\]\%#', 'char': '<BS>', 'input': '<BS><BS>'},
\ {'at': '\\\%#', 'char': '[', 'input': '['},
\ ])
call urules.add('{}', [
\ {'at': '\%#', 'char': '{', 'input': '{}<Left>'},
\ {'at': '\%#}', 'char': '}', 'input': '<Right>'},
\ {'at': '{\%#}', 'char': '<BS>', 'input': '<BS><Del>'},
+ \ {'at': '{}\%#', 'char': '<BS>', 'input': '<BS><BS>'},
\ {'at': '\\\%#', 'char': '{', 'input': '{'},
\ ])
call urules.add('''''', [
\ {'at': '\%#', 'char': '''', 'input': '''''<Left>'},
\ {'at': '\%#''\ze', 'char': '''', 'input': '<Right>'},
\ {'at': '''\%#''', 'char': '<BS>', 'input': '<BS><Del>'},
+ \ {'at': '''''\%#', 'char': '<BS>', 'input': '<BS><BS>'},
\ {'at': '\\\%#', 'char': '''', 'input': ''''},
\ ])
call urules.add('""', [
\ {'at': '\%#', 'char': '"', 'input': '""<Left>'},
\ {'at': '\%#"', 'char': '"', 'input': '<Right>'},
\ {'at': '"\%#"', 'char': '<BS>', 'input': '<BS><Del>'},
+ \ {'at': '""\%#', 'char': '<BS>', 'input': '<BS><BS>'},
\ {'at': '\\\%#', 'char': '"', 'input': '"'},
\ ])
call urules.add('``', [
\ {'at': '\%#', 'char': '`', 'input': '``<Left>'},
\ {'at': '\%#`', 'char': '`', 'input': '<Right>'},
\ {'at': '`\%#`', 'char': '<BS>', 'input': '<BS><Del>'},
+ \ {'at': '``\%#', 'char': '<BS>', 'input': '<BS><BS>'},
\ {'at': '\\\%#', 'char': '`', 'input': '`'},
\ ])
call urules.add('English', [
View
66 t/api.vim
@@ -553,12 +553,18 @@ describe 'The default configuration'
\ ["x", ['"x"'], 1, 3 - 1],
\ ["\"", ['"x"'], 1, 4 - 1],
\ ],
- \ '"" undo': [
+ \ '"" undo #1': [
\ ["\"", ['""'], 1, 2 - 1],
\ ["x", ['"x"'], 1, 3 - 1],
\ ["\<BS>", ['""'], 1, 2 - 1],
\ ["\<BS>", [''], 1, 0 + 1],
\ ],
+ \ '"" undo #2': [
+ \ ["x", ['x'], 1, 2 - 1],
+ \ ["\"", ['x""'], 1, 3 - 1],
+ \ ["\"", ['x""'], 1, 4 - 1],
+ \ ["\<BS>", ['x'], 1, 2 - 1],
+ \ ],
\ '''''': [
\ ["'", [''''''], 1, 2 - 1],
\ ["'", [''''''], 1, 3 - 1],
@@ -587,12 +593,18 @@ describe 'The default configuration'
\ ["x", ['''x'''], 1, 3 - 1],
\ ["'", ['''x'''], 1, 4 - 1],
\ ],
- \ ''''' undo': [
+ \ ''''' undo #1': [
\ ["'", [''''''], 1, 2 - 1],
\ ["x", ['''x'''], 1, 3 - 1],
\ ["\<BS>", [''''''], 1, 2 - 1],
\ ["\<BS>", [''], 1, 0 + 1],
\ ],
+ \ ''''' undo #2': [
+ \ ["x", ['x'], 1, 2 - 1],
+ \ ["\<C-v>'", ['x'''], 1, 3 - 1],
+ \ ["\<C-v>'", ['x'''''], 1, 4 - 1],
+ \ ["\<BS>", ['x'], 1, 2 - 1],
+ \ ],
\ '() complete': [
\ ["(", ['()'], 1, 2 - 1],
\ ],
@@ -609,12 +621,18 @@ describe 'The default configuration'
\ ["x", ['(x)'], 1, 3 - 1],
\ [")", ['(x)'], 1, 4 - 1],
\ ],
- \ '() undo': [
+ \ '() undo #1': [
\ ["(", ['()'], 1, 2 - 1],
\ ["x", ['(x)'], 1, 3 - 1],
\ ["\<BS>", ['()'], 1, 2 - 1],
\ ["\<BS>", [''], 1, 0 + 1],
\ ],
+ \ '() undo #2': [
+ \ ["x", ['x'], 1, 2 - 1],
+ \ ["(", ['x()'], 1, 3 - 1],
+ \ [")", ['x()'], 1, 4 - 1],
+ \ ["\<BS>", ['x'], 1, 2 - 1],
+ \ ],
\ 'English': [
\ ["Let", ['Let'], 1, 4 - 1],
\ ["'", ['Let'''], 1, 5 - 1],
@@ -639,12 +657,18 @@ describe 'The default configuration'
\ ["x", ['[x]'], 1, 3 - 1],
\ ["]", ['[x]'], 1, 4 - 1],
\ ],
- \ '[] undo': [
+ \ '[] undo #1': [
\ ["[", ['[]'], 1, 2 - 1],
\ ["x", ['[x]'], 1, 3 - 1],
\ ["\<BS>", ['[]'], 1, 2 - 1],
\ ["\<BS>", [''], 1, 0 + 1],
\ ],
+ \ '[] undo #2': [
+ \ ["x", ['x'], 1, 2 - 1],
+ \ ["[", ['x[]'], 1, 3 - 1],
+ \ ["]", ['x[]'], 1, 4 - 1],
+ \ ["\<BS>", ['x'], 1, 2 - 1],
+ \ ],
\ '`` complete': [
\ ["`", ['``'], 1, 2 - 1],
\ ],
@@ -661,12 +685,18 @@ describe 'The default configuration'
\ ["x", ['`x`'], 1, 3 - 1],
\ ["`", ['`x`'], 1, 4 - 1],
\ ],
- \ '`` undo': [
+ \ '`` undo #1': [
\ ["`", ['``'], 1, 2 - 1],
\ ["x", ['`x`'], 1, 3 - 1],
\ ["\<BS>", ['``'], 1, 2 - 1],
\ ["\<BS>", [''], 1, 0 + 1],
\ ],
+ \ '`` undo #2': [
+ \ ["x", ['x'], 1, 2 - 1],
+ \ ["`", ['x``'], 1, 3 - 1],
+ \ ["`", ['x``'], 1, 4 - 1],
+ \ ["\<BS>", ['x'], 1, 2 - 1],
+ \ ],
\ '{} complete': [
\ ["{", ['{}'], 1, 2 - 1],
\ ],
@@ -683,12 +713,18 @@ describe 'The default configuration'
\ ["x", ['{x}'], 1, 3 - 1],
\ ["}", ['{x}'], 1, 4 - 1],
\ ],
- \ '{} undo': [
+ \ '{} undo #1': [
\ ["{", ['{}'], 1, 2 - 1],
\ ["x", ['{x}'], 1, 3 - 1],
\ ["\<BS>", ['{}'], 1, 2 - 1],
\ ["\<BS>", [''], 1, 0 + 1],
\ ],
+ \ '{} undo #2': [
+ \ ["x", ['x'], 1, 2 - 1],
+ \ ["{", ['x{}'], 1, 3 - 1],
+ \ ["}", ['x{}'], 1, 4 - 1],
+ \ ["\<BS>", ['x'], 1, 2 - 1],
+ \ ],
\ }
end
@@ -727,32 +763,38 @@ describe 'The default configuration'
\ '() escape',
\ '() leave #1',
\ '() leave #2',
- \ '() undo',
+ \ '() undo #1',
+ \ '() undo #2',
\ '[] complete',
\ '[] escape',
\ '[] leave #1',
\ '[] leave #2',
- \ '[] undo',
+ \ '[] undo #1',
+ \ '[] undo #2',
\ '{} complete',
\ '{} escape',
\ '{} leave #1',
\ '{} leave #2',
- \ '{} undo',
+ \ '{} undo #1',
+ \ '{} undo #2',
\ ''''' complete',
\ ''''' escape',
\ ''''' leave #1',
\ ''''' leave #2',
- \ ''''' undo',
+ \ ''''' undo #1',
+ \ ''''' undo #2',
\ '"" complete',
\ '"" escape',
\ '"" leave #1',
\ '"" leave #2',
- \ '"" undo',
+ \ '"" undo #1',
+ \ '"" undo #2',
\ '`` complete',
\ '`` escape',
\ '`` leave #1',
\ '`` leave #2',
- \ '`` undo',
+ \ '`` undo #1',
+ \ '`` undo #2',
\ 'English',
\ ])
end

0 comments on commit ab606eb

Please sign in to comment.