Browse Source

LibGUI: Don't delete within a line if the line is empty

dylanbobb 4 years ago
parent
commit
e24f1dfbe1
1 changed files with 3 additions and 0 deletions
  1. 3 0
      Userland/Libraries/LibGUI/TextDocument.cpp

+ 3 - 0
Userland/Libraries/LibGUI/TextDocument.cpp

@@ -879,6 +879,9 @@ void TextDocument::remove(const TextRange& unnormalized_range)
     if (range.start().line() == range.end().line()) {
     if (range.start().line() == range.end().line()) {
         // Delete within same line.
         // Delete within same line.
         auto& line = this->line(range.start().line());
         auto& line = this->line(range.start().line());
+        if (line.length() == 0)
+            return;
+
         bool whole_line_is_selected = range.start().column() == 0 && range.end().column() == line.length();
         bool whole_line_is_selected = range.start().column() == 0 && range.end().column() == line.length();
 
 
         if (whole_line_is_selected) {
         if (whole_line_is_selected) {