mirror of
https://github.com/junegunn/vim-easy-align.git
synced 2025-11-11 11:23:49 -05:00
Better handling of tab characters using strdisplaywidth
This commit is contained in:
@@ -67,9 +67,9 @@ let s:shorthand = {
|
|||||||
\ 'mode_sequence': 'm', 'ignores': 'ig', 'filter': 'f'
|
\ 'mode_sequence': 'm', 'ignores': 'ig', 'filter': 'f'
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
if exists("*strwidth")
|
if exists("*strdisplaywidth")
|
||||||
function! s:strwidth(str)
|
function! s:strwidth(str)
|
||||||
return strwidth(a:str) + len(matchstr(a:str, '^\t*')) * (&tabstop - 1)
|
return strdisplaywidth(a:str)
|
||||||
endfunction
|
endfunction
|
||||||
else
|
else
|
||||||
function! s:strwidth(str)
|
function! s:strwidth(str)
|
||||||
|
|||||||
@@ -117,4 +117,26 @@ Expect:
|
|||||||
n2gv = {}
|
n2gv = {}
|
||||||
n2vt = {}
|
n2vt = {}
|
||||||
|
|
||||||
|
Given (Tab-indented code (#20)):
|
||||||
|
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 = {}
|
||||||
|
|
||||||
Include: include/teardown.vader
|
Include: include/teardown.vader
|
||||||
|
|||||||
Reference in New Issue
Block a user