Merge pull request #83822 from jsjtxietian/fix-can-not-uncomment-in-text-shader-editor

Fix unable to uncomment code in text shader editor
This commit is contained in:
Rémi Verschelde 2023-10-28 12:31:14 +02:00
commit b6c941fe9c
No known key found for this signature in database
GPG Key ID: C3336907360768E1

View File

@ -1514,8 +1514,8 @@ void CodeTextEditor::toggle_inline_comment(const String &delimiter) {
// Empty lines should not be counted. // Empty lines should not be counted.
bool is_empty = text_editor->get_line(line).strip_edges().is_empty(); bool is_empty = text_editor->get_line(line).strip_edges().is_empty();
is_all_empty = is_all_empty && is_empty; is_all_empty = is_all_empty && is_empty;
// `.left(1)` here because get_delimiter_start_key will return `##` instead of `#` when there is multiple comment delimiter in a line. // get_delimiter_start_key will return `##` instead of `#` when there is multiple comment delimiter in a line.
if (!is_empty && (delimiter_idx == -1 || text_editor->get_delimiter_start_key(delimiter_idx).left(1) != delimiter)) { if (!is_empty && (delimiter_idx == -1 || !text_editor->get_delimiter_start_key(delimiter_idx).begins_with(delimiter))) {
is_commented = false; is_commented = false;
break; break;
} }