diff options
| -rw-r--r-- | doc/ScintillaHistory.html | 4 | ||||
| -rw-r--r-- | src/Editor.cxx | 8 | ||||
| -rw-r--r-- | test/simpleTests.py | 18 |
3 files changed, 30 insertions, 0 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 65d6b9fcb..342a87d51 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -610,6 +610,10 @@ <a href="https://sourceforge.net/p/scintilla/bugs/2487/">Bug #2487</a>. </li> <li> + Fix bug when indenting rectangular selection. + <a href="https://sourceforge.net/p/scintilla/feature-requests/1567/">Feature #1567</a>. + </li> + <li> On Win32, force autocompletion list colours to be opaque. Enlarge bitmap to avoid visible blank background between items. <a href="https://sourceforge.net/p/scintilla/bugs/2482/">Bug #2482</a>. diff --git a/src/Editor.cxx b/src/Editor.cxx index 9f3999b08..eb31d40f9 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -4155,6 +4155,12 @@ int Editor::KeyDownWithModifiers(Keys key, KeyMod modifiers, bool *consumed) { void Editor::Indent(bool forwards, bool lineIndent) { UndoGroup ug(pdoc); + // Avoid problems with recalculating rectangular range multiple times by temporarily + // treating rectangular selection as multiple stream selection. + const Selection::SelTypes selType = sel.selType; + if (sel.IsRectangular()) { + sel.selType = Selection::SelTypes::stream; + } for (size_t r=0; r<sel.Count(); r++) { const Sci::Line lineOfAnchor = pdoc->SciLineFromPosition(sel.Range(r).anchor.Position()); @@ -4231,6 +4237,8 @@ void Editor::Indent(bool forwards, bool lineIndent) { } } } + sel.selType = selType; // Restore rectangular mode + ThinRectangularRange(); ContainerNeedsUpdate(Update::Selection); } diff --git a/test/simpleTests.py b/test/simpleTests.py index 0389d6dbc..020b72e99 100644 --- a/test/simpleTests.py +++ b/test/simpleTests.py @@ -312,6 +312,24 @@ class TestSimple(unittest.TestCase): self.assertEqual(self.ed.Contents(), b"\tx\tb") self.assertEqual(self.ed.GetLineIndentPosition(0), 1) + def testRectangularIndent(self): + self.ed.VirtualSpaceOptions = 3 + self.ed.AddText(3, b"\n\n\n") + self.ed.RectangularSelectionAnchor = 2 + self.ed.RectangularSelectionCaret = 0 + self.ed.TabIndents = 0 + self.ed.UseTabs = 1 + self.ed.Tab() + self.assertEqual(self.ed.Contents(), b"\t\n\t\n\t\n") + self.assertEqual(self.ed.GetSelectionSerialized(), b'T#2,5-1') + self.assertEqual(self.ed.GetSelectionNAnchor(0), 5) + self.assertEqual(self.ed.GetSelectionNCaret(0), 5) + self.assertEqual(self.ed.GetSelectionNAnchor(1), 3) + self.assertEqual(self.ed.GetSelectionNCaret(1), 3) + self.assertEqual(self.ed.GetSelectionNAnchor(2), 1) + self.assertEqual(self.ed.GetSelectionNCaret(2), 1) + self.ed.VirtualSpaceOptions = 0 + def testGetCurLine(self): self.ed.AddText(1, b"x") data = ctypes.create_string_buffer(b"\0" * 100) |
