Skip to content

Commit

Permalink
Backport PR #23044 on branch 6.x (PR: Fix `FoldingPanel._expand_selec…
Browse files Browse the repository at this point in the history
…tion` to not select text an extra line below a folded region (Editor)) (#23046)
  • Loading branch information
meeseeksmachine authored Nov 21, 2024
1 parent 4ab6ec0 commit 4bdba81
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
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

0 comments on commit 4bdba81

Please sign in to comment.