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 ```yaml
mysql: mysql:
# JDBC driver for MySQL database # JDBC driver for MySQL database:
driver: com.mysql.jdbc.Driver driver: com.mysql.jdbc.Driver
# JDBC URL for the connection (jdbc:mysql://HOSTNAME/DATABASE) # JDBC URL for the connection (jdbc:mysql://HOSTNAME/DATABASE)
url: jdbc:mysql://localhost/test url: jdbc:mysql://localhost/test
database: 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, a:lc - a:fc + 1) :
\ strpart(getline(line), a:fc - 1), \ strpart(getline(line), a:fc - 1),
\ pattern.'\zs') \ pattern.'\zs')
let concat = 0
if empty(ignored_syntax) if empty(ignored_syntax)
let tokens = raw_tokens let tokens = raw_tokens
else else
" Concat adjacent tokens that are split by ignorable delimiters " Concat adjacent tokens that are split by ignorable delimiters
let tokens = [] let tokens = []
let idx = 0 let idx = 0
let concat = 0
for token in raw_tokens for token in raw_tokens
let idx += len(token) let idx += len(token)
if concat 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]) let tokens = extend([join(tokens[0:1], '')], tokens[2:-1])
endif endif
" Skip comment line
if concat && len(tokens) == 1
let tokens = []
endif
" Remember tokens for subsequent recursive calls " Remember tokens for subsequent recursive calls
let a:all_tokens[line] = tokens let a:all_tokens[line] = tokens
else else