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

PR: Fix FoldingPanel._expand_selection to not select text an extra line below a folded region (Editor) #23044

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion spyder/plugins/editor/panels/codefolding.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,11 +709,13 @@ def _expand_selection(self):
start_line in self.folding_regions
and self.folding_status[start_line]
):
end_line = self.folding_regions[start_line] + 1
end_line = self.folding_regions[start_line]

if cursor.hasSelection():
tc = TextHelper(self.editor).select_lines(
start_line, end_line)
tc.movePosition(tc.MoveOperation.NextBlock,
tc.MoveMode.KeepAnchor)

if tc.selectionStart() > cursor.selectionStart():
start = cursor.selectionStart()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def myfunc2():
3 , 4] # Arbitary Code
x[0] = 2 # Desired break
print(x[1]) # Arbitary Code

# don't delete this comment
responses = {
100: ('Continue', 'Request received, please continue'),
101: ('Switching Protocols','Switching to new protocol'),
Expand Down Expand Up @@ -182,6 +182,9 @@ def fold_and_delete_region(key):
assert "print" not in editor.toPlainText()
assert editor.blockCount() == 31

# Check line after folded region was not removed
assert "# don't delete this comment" in editor.toPlainText()

# Press Ctrl+Z
qtbot.keyClick(editor, Qt.Key_Z, Qt.ControlModifier)

Expand All @@ -193,6 +196,9 @@ def fold_and_delete_region(key):
assert "print" not in editor.toPlainText()
assert editor.blockCount() == 31

# Check line after folded region was not removed
assert "# don't delete this comment" in editor.toPlainText()

# Press Ctrl+Z again
qtbot.keyClick(editor, Qt.Key_Z, Qt.ControlModifier)

Expand Down
Loading