From 82a7704fee6ef86953857a6d46cc18923888704f Mon Sep 17 00:00:00 2001
From: Neil SCI_GETLINEENDPOSITION(int line)
This returns the position at the end of the line, before any line end characters. If line
- is the last line in the document (which does not have any end of line characters), the result is the size of the
- document. If line is negative or line >= , the result is undefined.line is negative the result is undefined.
SCI_LINELENGTH(int line)
This returns the length of the line, including any line end characters. If line
diff --git a/src/Document.cxx b/src/Document.cxx
index b8ab420fd..78aa22794 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -279,7 +279,7 @@ int SCI_METHOD Document::LineStart(int line) const {
}
int SCI_METHOD Document::LineEnd(int line) const {
- if (line == LinesTotal() - 1) {
+ if (line >= LinesTotal() - 1) {
return LineStart(line + 1);
} else {
int position = LineStart(line + 1);
diff --git a/test/simpleTests.py b/test/simpleTests.py
index e814f45ca..03deb566d 100644
--- a/test/simpleTests.py
+++ b/test/simpleTests.py
@@ -86,6 +86,12 @@ class TestSimple(unittest.TestCase):
self.assertEquals(self.ed.Anchor, 0)
self.assertEquals(self.ed.CurrentPos, 1)
+ def testBeyonEnd(self):
+ self.ed.AddText(1, b"x")
+ self.assertEquals(self.ed.GetLineEndPosition(0), 1)
+ self.assertEquals(self.ed.GetLineEndPosition(1), 1)
+ self.assertEquals(self.ed.GetLineEndPosition(2), 1)
+
def testSelection(self):
self.assertEquals(self.ed.CurrentPos, 0)
self.assertEquals(self.ed.Anchor, 0)
--
cgit v1.2.3