Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix toggle comment not moving caret #73440

Merged
merged 1 commit into from
Feb 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions editor/code_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1629,14 +1629,15 @@ void CodeTextEditor::toggle_inline_comment(const String &delimiter) {
int selection_i = 0;
int offset = (is_commented ? -1 : 1) * delimiter.length();
for (const int &c2 : caret_edit_order) {
bool is_line_selection = text_editor->has_selection(c2) && text_editor->get_selection_from_line(c2) < text_editor->get_selection_to_line(c2);
if (text_editor->get_caret_line(c2) >= from && text_editor->get_caret_line(c2) <= to) {
int caret_col = caret_cols[caret_i++];
caret_col += (caret_col == 0) ? 0 : offset;
caret_col += (is_line_selection && caret_col == 0) ? 0 : offset;
text_editor->set_caret_column(caret_col, c2 == 0, c2);
}
if (text_editor->has_selection(c2) && text_editor->get_selection_to_line(c2) >= from && text_editor->get_selection_to_line(c2) <= to) {
int from_col = text_editor->get_selection_from_column(c2);
from_col += (from_col == 0) ? 0 : offset;
from_col += (is_line_selection && from_col == 0) ? 0 : offset;
int to_col = selection_to_cols[selection_i++];
to_col += (to_col == 0) ? 0 : offset;
text_editor->select(
Expand Down