Fix: trailing delimiter not ignored (#4)

This commit is contained in:
Junegunn Choi
2013-08-01 23:28:05 +09:00
parent 5f59570c9f
commit 9b20830c70
2 changed files with 8 additions and 3 deletions

View File

@@ -90,12 +90,12 @@ Formatting YAML (or JSON)
```yaml
mysql:
# JDBC driver for MySQL database
# JDBC driver for MySQL database:
driver: com.mysql.jdbc.Driver
# JDBC URL for the connection (jdbc:mysql://HOSTNAME/DATABASE)
url: jdbc:mysql://localhost/test
database: test
user:r00t
"user:pass":r00t:pa55
```

View File

@@ -89,13 +89,13 @@ function! s:do_align(just, all_tokens, fl, ll, fc, lc, pattern, nth, ml, mr, sti
\ strpart(getline(line), a:fc - 1, a:lc - a:fc + 1) :
\ strpart(getline(line), a:fc - 1),
\ pattern.'\zs')
let concat = 0
if empty(ignored_syntax)
let tokens = raw_tokens
else
" Concat adjacent tokens that are split by ignorable delimiters
let tokens = []
let idx = 0
let concat = 0
for token in raw_tokens
let idx += len(token)
if concat
@@ -112,6 +112,11 @@ function! s:do_align(just, all_tokens, fl, ll, fc, lc, pattern, nth, ml, mr, sti
let tokens = extend([join(tokens[0:1], '')], tokens[2:-1])
endif
" Skip comment line
if concat && len(tokens) == 1
let tokens = []
endif
" Remember tokens for subsequent recursive calls
let a:all_tokens[line] = tokens
else