Fix align support with aligntab = true
This commit is contained in:
parent
79b193d2be
commit
965cd8e0c3
|
@ -1262,17 +1262,18 @@ void align(Context& context, NormalParams)
|
||||||
for (auto& sel : col)
|
for (auto& sel : col)
|
||||||
{
|
{
|
||||||
auto insert_coord = sel->min();
|
auto insert_coord = sel->min();
|
||||||
auto lastcol = get_column(buffer, tabstop, sel->cursor());
|
ColumnCount lastcol = get_column(buffer, tabstop, sel->cursor());
|
||||||
|
ColumnCount inscount = maxcol - lastcol;
|
||||||
String padstr;
|
String padstr;
|
||||||
if (not use_tabs)
|
if (not use_tabs)
|
||||||
padstr = String{ ' ', maxcol - lastcol };
|
padstr = String{ ' ', inscount };
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto inscol = get_column(buffer, tabstop, insert_coord);
|
ColumnCount inscol = get_column(buffer, tabstop, insert_coord);
|
||||||
auto targetcol = maxcol - (lastcol - inscol);
|
ColumnCount targetcol = inscol + inscount;
|
||||||
auto tabcol = inscol - (inscol % tabstop);
|
ColumnCount tabcol = inscol - (inscol % tabstop);
|
||||||
auto tabs = (targetcol - tabcol) / tabstop;
|
CharCount tabs = (int)((targetcol - tabcol) / tabstop);
|
||||||
auto spaces = targetcol - (tabs ? (tabcol + tabs * tabstop) : inscol);
|
CharCount spaces = (int)(targetcol - (tabs ? (tabcol + (int)tabs * tabstop) : inscol));
|
||||||
padstr = String{ '\t', tabs } + String{ ' ', spaces };
|
padstr = String{ '\t', tabs } + String{ ' ', spaces };
|
||||||
}
|
}
|
||||||
buffer.insert(insert_coord, std::move(padstr));
|
buffer.insert(insert_coord, std::move(padstr));
|
||||||
|
|
1
test/unit/align-tab/cmd
Normal file
1
test/unit/align-tab/cmd
Normal file
|
@ -0,0 +1 @@
|
||||||
|
&
|
2
test/unit/align-tab/in
Normal file
2
test/unit/align-tab/in
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
if (%(v)alid)
|
||||||
|
%(x)
|
2
test/unit/align-tab/out
Normal file
2
test/unit/align-tab/out
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
if (valid)
|
||||||
|
x
|
2
test/unit/align-tab/rc
Normal file
2
test/unit/align-tab/rc
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
set buffer tabstop 4
|
||||||
|
set buffer aligntab true
|
Loading…
Reference in New Issue
Block a user