From 9b20830c7088484156e0853b4194c94a97782d8f Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Thu, 1 Aug 2013 23:28:05 +0900 Subject: [PATCH] Fix: trailing delimiter not ignored (#4) --- EXAMPLES.md | 4 ++-- autoload/easy_align.vim | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/EXAMPLES.md b/EXAMPLES.md index 368ee92..d3bfa98 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -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 ``` diff --git a/autoload/easy_align.vim b/autoload/easy_align.vim index 1a6e48a..d3a35a9 100644 --- a/autoload/easy_align.vim +++ b/autoload/easy_align.vim @@ -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