diff options
-rw-r--r-- | doc/ScintillaDoc.html | 6 | ||||
-rw-r--r-- | src/Document.cxx | 2 | ||||
-rw-r--r-- | test/simpleTests.py | 6 |
3 files changed, 10 insertions, 4 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 8c7499ed9..f408dafad 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -1306,9 +1306,9 @@ struct Sci_TextToFind { <p><b id="SCI_GETLINEENDPOSITION">SCI_GETLINEENDPOSITION(int line)</b><br /> This returns the position at the end of the line, before any line end characters. If <code>line</code> - 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 <code>line</code> is negative or <code>line</code> >= <a class="message" - href="#SCI_GETLINECOUNT"><code>SCI_GETLINECOUNT()</code></a>, the result is undefined.</p> + is the last line in the document (which does not have any end of line characters) or greater, + the result is the size of the document. + If <code>line</code> is negative the result is undefined.</p> <p><b id="SCI_LINELENGTH">SCI_LINELENGTH(int line)</b><br /> This returns the length of the line, including any line end characters. If <code>line</code> 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) |