1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-29 14:44:56 +03:00

Replace tab characters with spaces in info/echo

This is tricky to fix better than that as tabs make text length
dependent on where it will get displayed and what preceedes it.

Also fix an issue with empty info title

Fixes #2237
This commit is contained in:
Maxime Coste 2019-11-24 17:25:14 +11:00
parent 34f48cc851
commit 6fd486c65e
3 changed files with 4 additions and 4 deletions

View File

@ -425,9 +425,9 @@ void Client::info_show(StringView title, StringView content, BufferCoord anchor,
{
if (not content.empty() and content.back() == '\n')
content = content.substr(0, content.length() - 1);
info_show({title.str(), Face{}},
info_show(title.empty() ? DisplayLine{} : DisplayLine{title.str(), Face{}},
content | split<StringView>('\n')
| transform([](StringView s) { return DisplayLine{s.str(), Face{}}; })
| transform([](StringView s) { return DisplayLine{replace(s, '\t', ' '), Face{}}; })
| gather<DisplayLineList>(),
anchor, style);
}

View File

@ -1277,7 +1277,7 @@ const CommandDesc echo_cmd = {
else if (parser.get_switch("markup"))
context.print_status(parse_display_line(message, context.faces()));
else
context.print_status({ std::move(message), context.faces()["StatusLine"] });
context.print_status({replace(message, '\t', ' '), context.faces()["StatusLine"]});
}
};

View File

@ -286,7 +286,7 @@ DisplayLine parse_display_line(StringView line, const FaceRegistry& faces, const
pos = closing + 1;
}
}
if (c == '\n') // line breaks are forbidden, replace with space
if (c == '\n' or c == '\t') // line breaks and tabs are forbidden, replace with space
{
content += StringView{pos, it+1};
content.back() = ' ';