aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMichael Heath <unknown>2022-11-28 17:59:01 +1100
committerMichael Heath <unknown>2022-11-28 17:59:01 +1100
commit8cedd574bc15453d86926a71f9a8197dc5fdb5ee (patch)
treede6d7211fe95248122e9595992537090fd9cd859
parenta179c1bd5f83c7b6c649fadbf98ffb2309e50adc (diff)
downloadscintilla-mirror-8cedd574bc15453d86926a71f9a8197dc5fdb5ee.tar.gz
Bug [#2363]. Change 'paragraph up' commands SCI_PARAUP and SCI_PARAUPEXTEND to
go to the start position of the paragraph containing the caret. Only if the caret is already at the start of the paragraph will it go to the start of the previous paragraph.
-rw-r--r--doc/ScintillaHistory.html8
-rw-r--r--src/Document.cxx5
-rw-r--r--test/simpleTests.py40
3 files changed, 52 insertions, 1 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index 2f9cf9d82..8bcd84c4b 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -574,6 +574,7 @@
</tr><tr>
<td>Reinhard Nißl</td>
<td>Ferdinand Oeinck</td>
+ <td>Michael Heath</td>
</tr>
</table>
<h2>Releases</h2>
@@ -602,6 +603,13 @@
<a href="https://sourceforge.net/p/scintilla/feature-requests/1459/">Feature #1459</a>.
</li>
<li>
+ Change 'paragraph up' commands SCI_PARAUP and SCI_PARAUPEXTEND to
+ go to the start position of the paragraph containing the caret.
+ Only if the caret is already at the start of the paragraph will it go to the start
+ of the previous paragraph.
+ <a href="https://sourceforge.net/p/scintilla/bugs/2363/">Bug #2363</a>.
+ </li>
+ <li>
On Win32, avoid blurry display with DirectWrite in GDI scaling mode.
<a href="https://sourceforge.net/p/scintilla/bugs/2344/">Bug #2344</a>.
</li>
diff --git a/src/Document.cxx b/src/Document.cxx
index c67aae125..7afe10701 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -1772,7 +1772,10 @@ bool Document::IsWhiteLine(Sci::Line line) const {
Sci::Position Document::ParaUp(Sci::Position pos) const {
Sci::Line line = SciLineFromPosition(pos);
- line--;
+ const Sci::Position start = LineStart(line);
+ if (pos == start) {
+ line--;
+ }
while (line >= 0 && IsWhiteLine(line)) { // skip empty lines
line--;
}
diff --git a/test/simpleTests.py b/test/simpleTests.py
index 31ae42535..a16b940fd 100644
--- a/test/simpleTests.py
+++ b/test/simpleTests.py
@@ -1021,6 +1021,46 @@ class TestKeyCommands(unittest.TestCase):
self.ed.DocumentEndExtend()
self.assertEquals(self.selRange(), (10, 3))
+ def testParagraphMove(self):
+ example = b"a\n\nbig\n\n\n\nboat"
+ self.ed.AddText(len(example), example)
+ start1 = 0 # Before 'a'
+ start2 = 3 # Before 'big'
+ start3 = 10 # Before 'boat'
+
+ # Paragraph 2 to 1
+ self.ed.SetSel(start2, start2)
+ self.ed.ParaUp()
+ self.assertEquals(self.selRange(), (start1, start1))
+ self.ed.ParaDown()
+ self.assertEquals(self.selRange(), (start2, start2))
+ self.ed.SetSel(start2, start2)
+ self.ed.ParaUpExtend()
+ self.assertEquals(self.selRange(), (start1, start2))
+ self.ed.ParaDownExtend()
+ self.assertEquals(self.selRange(), (start2, start2))
+
+ # Inside paragraph 2 to start paragraph 2
+ mid2 = start2+1
+ self.ed.SetSel(mid2, mid2)
+ # Next line behaved differently before change for bug #2363
+ self.ed.ParaUp()
+ self.assertEquals(self.selRange(), (start2, start2))
+ self.ed.ParaDown()
+ self.assertEquals(self.selRange(), (start3, start3))
+ self.ed.SetSel(mid2, mid2)
+ self.ed.ParaUpExtend()
+ self.assertEquals(self.selRange(), (start2, mid2))
+ self.ed.ParaDownExtend()
+ self.assertEquals(self.selRange(), (start3, mid2))
+
+ # Paragraph 3 to 2
+ self.ed.SetSel(start3, start3)
+ self.ed.ParaUp()
+ self.assertEquals(self.selRange(), (start2, start2))
+ self.ed.ParaDown()
+ self.assertEquals(self.selRange(), (start3, start3))
+
class TestMarkers(unittest.TestCase):