Skip to content

Commit

Permalink
Clamp negative line/columns when converting to points
Browse files Browse the repository at this point in the history
  • Loading branch information
Nimaoth committed Oct 5, 2024
1 parent 346a88e commit a042113
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/misc/rope_utils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import custom_async, custom_unicode, util
{.push gcsafe.}
{.push raises: [].}

func toPoint*(cursor: api.Cursor): Point = Point.init(cursor.line, cursor.column)
func toPoint*(cursor: api.Cursor): Point = Point.init(max(cursor.line, 0), max(cursor.column, 0))
func toPointRange*(selection: Selection): tuple[first, last: Point] = (selection.first.toPoint, selection.last.toPoint)
func toRange*(selection: Selection): Range[Point] = selection.first.toPoint...selection.last.toPoint
func toCursor*(point: Point): api.Cursor = (point.row.int, point.column.int)
Expand Down

0 comments on commit a042113

Please sign in to comment.