From 5e87c798d2398ce033e43c7e616001612f025824 Mon Sep 17 00:00:00 2001 From: Vinicius Date: Sun, 25 Jul 2021 02:14:37 -0300 Subject: [PATCH] TextDocument: Fix indentation duplicating spaces Auto indentation will consider only leading spaces before the cursor. Fixes #8973. --- Userland/Libraries/LibGUI/TextDocument.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Userland/Libraries/LibGUI/TextDocument.cpp b/Userland/Libraries/LibGUI/TextDocument.cpp index 9d7b6a0bdb..5c7a1d92ac 100644 --- a/Userland/Libraries/LibGUI/TextDocument.cpp +++ b/Userland/Libraries/LibGUI/TextDocument.cpp @@ -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) {