Fix #20 - Alignment with tabs inserting spaces

This commit is contained in:
Junegunn Choi
2013-11-20 07:27:39 +09:00
parent ea1ea51ef1
commit 3921d0bab3
3 changed files with 82 additions and 2 deletions

View File

@@ -546,7 +546,7 @@ function! s:do_align(todo, modes, all_tokens, all_delims, fl, ll, fc, lc, nth, r
" Adjust indentation of the lines starting with a delimiter
let lpad = ''
if nth == 0
let ipad = repeat(' ', min_indent - len(token.ml))
let ipad = repeat(' ', min_indent - s:strwidth(token.ml))
if mode ==? 'l'
let token = ipad . token
else

View File

@@ -1,3 +1,6 @@
Execute:
Save &tabstop
Given (Table):
|a|b|c|d|
| -|-|>-|-|
@@ -40,3 +43,80 @@ Execute:
Expect:
a <|>b <|>c <|
aa<|>bb<|>cc<|
Given (Tab-indented code (#20)):
class MyUnitTest(unittest.TestCase):
def test_base(self):
n2f = {}
n2v = {}
f2v = {}
n2gv = {}
n2vt = {}
Execute:
set tabstop=1
%EasyAlign=
Expect:
class MyUnitTest(unittest.TestCase):
def test_base(self):
n2f = {}
n2v = {}
f2v = {}
n2gv = {}
n2vt = {}
Execute:
set tabstop=2
%EasyAlign=
Expect:
class MyUnitTest(unittest.TestCase):
def test_base(self):
n2f = {}
n2v = {}
f2v = {}
n2gv = {}
n2vt = {}
Execute:
set tabstop=4
%EasyAlign=
Expect:
class MyUnitTest(unittest.TestCase):
def test_base(self):
n2f = {}
n2v = {}
f2v = {}
n2gv = {}
n2vt = {}
Execute:
set tabstop=8
%EasyAlign=
Expect:
class MyUnitTest(unittest.TestCase):
def test_base(self):
n2f = {}
n2v = {}
f2v = {}
n2gv = {}
n2vt = {}
Execute:
set tabstop=12
%EasyAlign=
Expect:
class MyUnitTest(unittest.TestCase):
def test_base(self):
n2f = {}
n2v = {}
f2v = {}
n2gv = {}
n2vt = {}
Execute:
Restore

View File

@@ -2,7 +2,7 @@ Execute (Clean up test environment):
Save g:easy_align_ignore_groups, g:easy_align_ignore_unmatched
Save g:easy_align_indentation, g:easy_align_delimiter_align
Save g:easy_align_interactive_modes, g:easy_align_bang_interactive_modes
Save g:easy_align_delimiters
Save g:easy_align_delimiters, &tabstop
Save mapleader
" TODO: revert after test