mirror of
https://github.com/mawww/kakoune.git
synced 2024-11-15 09:17:22 +03:00
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)
|
||||
{
|
||||
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;
|
||||
if (not use_tabs)
|
||||
padstr = String{ ' ', maxcol - lastcol };
|
||||
padstr = String{ ' ', inscount };
|
||||
else
|
||||
{
|
||||
auto inscol = get_column(buffer, tabstop, insert_coord);
|
||||
auto targetcol = maxcol - (lastcol - inscol);
|
||||
auto tabcol = inscol - (inscol % tabstop);
|
||||
auto tabs = (targetcol - tabcol) / tabstop;
|
||||
auto spaces = targetcol - (tabs ? (tabcol + tabs * tabstop) : inscol);
|
||||
ColumnCount inscol = get_column(buffer, tabstop, insert_coord);
|
||||
ColumnCount targetcol = inscol + inscount;
|
||||
ColumnCount tabcol = inscol - (inscol % tabstop);
|
||||
CharCount tabs = (int)((targetcol - tabcol) / tabstop);
|
||||
CharCount spaces = (int)(targetcol - (tabs ? (tabcol + (int)tabs * tabstop) : inscol));
|
||||
padstr = String{ '\t', tabs } + String{ ' ', spaces };
|
||||
}
|
||||
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