diff options
| author | Neil <nyamatongwe@gmail.com> | 2023-10-29 09:25:20 +1100 | 
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2023-10-29 09:25:20 +1100 | 
| commit | 60e0be1d49d4ba0e093a28bd3c2039f0c1ef8344 (patch) | |
| tree | 3ed361c7cd99c7be47e8d2ebad039bfbcb3c7093 | |
| parent | 29ff682132a9de383243794764bd12d9e43e4899 (diff) | |
| download | scintilla-mirror-60e0be1d49d4ba0e093a28bd3c2039f0c1ef8344.tar.gz | |
Bug [#2078]. Fix rectangular selections with SCI_MOVESELECTEDLINESUP and
SCI_MOVESELECTEDLINESDOWN.
| -rw-r--r-- | doc/ScintillaHistory.html | 4 | ||||
| -rw-r--r-- | src/Editor.cxx | 5 | ||||
| -rw-r--r-- | test/simpleTests.py | 14 | 
3 files changed, 22 insertions, 1 deletions
| diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 7d1d9f48f..d49ee81a0 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -599,6 +599,10 @@  	<a href="https://sourceforge.net/p/scintilla/bugs/2405/">Bug #2405</a>.  	</li>  	<li> +	Make SCI_MOVESELECTEDLINESUP and SCI_MOVESELECTEDLINESDOWN work for rectangular selections. +	<a href="https://sourceforge.net/p/scintilla/bugs/2078/">Bug #2078</a>. +	</li> +	<li>  	For Cocoa, fix invisible text on macOS 14 Sonoma.  	<a href="https://sourceforge.net/p/scintilla/bugs/2402/">Bug #2402</a>.  	</li> diff --git a/src/Editor.cxx b/src/Editor.cxx index ade5094f7..796279871 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -980,7 +980,10 @@ void Editor::VerticalCentreCaret() {  void Editor::MoveSelectedLines(int lineDelta) {  	if (sel.IsRectangular()) { -		return; +		// Convert to stream selection +		const SelectionRange rangeRectangular = sel.Rectangular(); +		sel.Clear(); +		sel.SetSelection(rangeRectangular);  	}  	// if selection doesn't start at the beginning of the line, set the new start diff --git a/test/simpleTests.py b/test/simpleTests.py index 653ab4338..d731ebbd6 100644 --- a/test/simpleTests.py +++ b/test/simpleTests.py @@ -668,6 +668,17 @@ class TestSimple(unittest.TestCase):  		self.ed.SetSel(1, 2)  		self.ed.MoveSelectedLinesDown()  		self.assertEqual(self.ed.Contents(), b"b2\na1\nc3") +		 +		# Exercise rectangular selection +		self.ed.EOLMode = self.ed.SC_EOL_LF +		self.ed.SetContents(b"a1\nb2\nc3") +		self.ed.RectangularSelectionAnchor = 1 +		self.ed.RectangularSelectionCaret = 4 +		# Check rectangular not stream +		self.assertEqual(self.ed.GetSelectionMode(), self.ed.SC_SEL_RECTANGLE) +		self.assertEqual(self.ed.Selections, 2) +		self.ed.MoveSelectedLinesDown() +		self.assertEqual(self.ed.Contents(), b"c3\na1\nb2")  		# Restore line end  		self.ed.EOLMode = lineEndType @@ -2044,6 +2055,7 @@ class TestModalSelection(unittest.TestCase):  		self.assertEqual(self.ed.GetSelectionNCaret(0), 1)  		self.assertEqual(self.ed.GetSelectionNAnchor(0), 1)  		self.ed.SelectionMode = self.ed.SC_SEL_STREAM +		self.assertEqual(self.ed.GetSelectionMode(), self.ed.SC_SEL_STREAM)  		self.assertEqual(self.ed.Selections, 1)  		self.assertEqual(self.ed.MainSelection, 0)  		self.assertEqual(self.ed.GetSelectionNCaret(0), 1) @@ -2067,6 +2079,7 @@ class TestModalSelection(unittest.TestCase):  		self.assertEqual(self.ed.GetSelectionNCaret(0), 1)  		self.assertEqual(self.ed.GetSelectionNAnchor(0), 1)  		self.ed.SelectionMode = self.ed.SC_SEL_RECTANGLE +		self.assertEqual(self.ed.GetSelectionMode(), self.ed.SC_SEL_RECTANGLE)  		self.assertEqual(self.ed.Selections, 1)  		self.assertEqual(self.ed.MainSelection, 0)  		self.assertEqual(self.ed.GetSelectionNCaret(0), 1) @@ -2092,6 +2105,7 @@ class TestModalSelection(unittest.TestCase):  		self.assertEqual(self.ed.GetSelectionNCaret(0), 1)  		self.assertEqual(self.ed.GetSelectionNAnchor(0), 1)  		self.ed.SelectionMode = self.ed.SC_SEL_LINES +		self.assertEqual(self.ed.GetSelectionMode(), self.ed.SC_SEL_LINES)  		self.assertEqual(self.ed.Selections, 1)  		self.assertEqual(self.ed.MainSelection, 0)  		self.assertEqual(self.ed.GetSelectionNCaret(0), 0) | 
