summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorVinicius <vtmsugimoto@gmail.com>2021-07-25 02:14:37 -0300
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-07-26 12:56:52 +0430
commit5e87c798d2398ce033e43c7e616001612f025824 (patch)
treee93d389a5ab5a234a654fdd87d61d0a03bd69781 /Userland
parent7d4e3f01ddb001764b872e2fb448c61c2895abe9 (diff)
downloadserenity-5e87c798d2398ce033e43c7e616001612f025824.zip
TextDocument: Fix indentation duplicating spaces
Auto indentation will consider only leading spaces before the cursor. Fixes #8973.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibGUI/TextDocument.cpp4
1 files changed, 4 insertions, 0 deletions
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) {