mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-30 06:37:14 +09:00
Do a bounds check for charpos function
This commit is contained in:
@@ -18,6 +18,9 @@ func FromCharPosStart(startLoc, startX, startY, loc int, buf *Buffer) (int, int)
|
|||||||
for charNum+lineLen <= loc {
|
for charNum+lineLen <= loc {
|
||||||
charNum += lineLen
|
charNum += lineLen
|
||||||
y++
|
y++
|
||||||
|
if y >= buf.NumLines {
|
||||||
|
return 0, 0
|
||||||
|
}
|
||||||
lineLen = Count(buf.Lines[y]) + 1
|
lineLen = Count(buf.Lines[y]) + 1
|
||||||
}
|
}
|
||||||
x = loc - charNum
|
x = loc - charNum
|
||||||
|
|||||||
Reference in New Issue
Block a user