Browse Source

Merge pull request #102601 from kitbdev/fix-script-toggle-comment-empty

Fix error when toggling comment with empty lines
Thaddeus Crews 1 tuần trước cách đây
mục cha
commit
a85fbd8647
1 tập tin đã thay đổi với 3 bổ sung1 xóa
  1. 3 1
      editor/gui/code_editor.cpp

+ 3 - 1
editor/gui/code_editor.cpp

@@ -1356,7 +1356,9 @@ void CodeTextEditor::toggle_inline_comment(const String &delimiter) {
 
 
 			if (is_commented) {
 			if (is_commented) {
 				int delimiter_column = text_editor->get_line(line).find(delimiter);
 				int delimiter_column = text_editor->get_line(line).find(delimiter);
-				text_editor->remove_text(line, delimiter_column, line, delimiter_column + delimiter.length());
+				if (delimiter_column != -1) {
+					text_editor->remove_text(line, delimiter_column, line, delimiter_column + delimiter.length());
+				}
 			} else {
 			} else {
 				text_editor->insert_text(delimiter, line, text_editor->get_first_non_whitespace_column(line));
 				text_editor->insert_text(delimiter, line, text_editor->get_first_non_whitespace_column(line));
 			}
 			}