diff options
author | Jean-Michel Bernard <jmb462@gmail.com> | 2023-04-07 17:44:37 +0200 |
---|---|---|
committer | Yuri Sizov <yuris@humnom.net> | 2023-04-07 17:44:37 +0200 |
commit | 1aa5fce3214323e1bfd25762acd3904304d360d1 (patch) | |
tree | b02826d1b87850e1a7e5adbd03a81ff4fdeb8733 /editor | |
parent | 7ef4e519f7f498de6cc4b3bee8046dc094c97230 (diff) |
Fix commenting collapsed function issue
(cherry picked from commit 68ad3338ef321772903896a3a99878f0b3bd6bf3)
Diffstat (limited to 'editor')
-rw-r--r-- | editor/code_editor.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 121af0170c..7d29dfad92 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -1587,11 +1587,17 @@ void CodeTextEditor::toggle_inline_comment(const String &delimiter) { Vector<int> caret_edit_order = text_editor->get_caret_index_edit_order(); caret_edit_order.reverse(); int last_line = -1; + int folded_to = 0; for (const int &c1 : caret_edit_order) { int from = _get_affected_lines_from(c1); - from += from == last_line ? 1 : 0; + from += from == last_line ? 1 + folded_to : 0; int to = _get_affected_lines_to(c1); last_line = to; + // If last line is folded, extends to the end of the folded section + if (text_editor->is_line_folded(to)) { + folded_to = text_editor->get_next_visible_line_offset_from(to + 1, 1) - 1; + to += folded_to; + } // Check first if there's any uncommented lines in selection. bool is_commented = true; for (int line = from; line <= to; line++) { |