Skip to content

Commit

Permalink
Use search pattern as delimiter if empty regex is given
Browse files Browse the repository at this point in the history
Close #78
  • Loading branch information
junegunn committed Mar 6, 2016
1 parent dd98d0a commit 0cb6b98
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 4 additions & 3 deletions autoload/easy_align.vim
Original file line number Diff line number Diff line change
Expand Up @@ -829,10 +829,11 @@ function! s:valid_regexp(regexp)
endfunction

function! s:test_regexp(regexp)
if !s:valid_regexp(a:regexp)
call s:exit('Invalid regular expression: '. a:regexp)
let regexp = empty(a:regexp) ? @/ : a:regexp
if !s:valid_regexp(regexp)
call s:exit('Invalid regular expression: '. regexp)
endif
return a:regexp
return regexp
endfunction

let s:shorthand_regex =
Expand Down
8 changes: 8 additions & 0 deletions test/commandline.vader
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ Expect:
ap><pl><e;><:;><;b><an><an><a:><:c><ak>e
da><ta><;;><ex><ch><an><ge><:;><::><fo> <rm><at

Execute (Use current search pattern as delimiter if empty regular expression is given):
/an
%EasyAlign*//

Expect:
apple;:;;b an an a::cake
data;;exch an ge:;::format

Given javascript (json):
var jdbc = {
// JDBC driver for MySQL database:
Expand Down

0 comments on commit 0cb6b98

Please sign in to comment.