1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:17:45 +00:00

TextDocument: Fix indentation duplicating spaces

Auto indentation will consider only leading spaces before the cursor.
Fixes #8973.
This commit is contained in:
Vinicius 2021-07-25 02:14:37 -03:00 committed by Ali Mohammad Pur
parent 7d4e3f01dd
commit 5e87c798d2

View file

@ -786,6 +786,10 @@ void InsertTextCommand::perform_formatting(const TextDocument::Client& client)
for (auto input_char : m_text) {
if (input_char == '\n') {
size_t spaces_at_end = 0;
if (column < line_indentation)
spaces_at_end = line_indentation - column;
line_indentation -= spaces_at_end;
builder.append('\n');
column = 0;
if (should_auto_indent) {