Skip to content

render_text accesses row before cursor validation #7

Description

@httpsVishu

hey, while exploring vimgpt/utils.py, i noticed that render_text() accesses the row before validating the cursor
current implementation:

cols = len(lines[rowOneIdx - 1])
with_cursor = insert_cursor(text, rowOneIdx, colOneIdx)

since validation happens inside insert_cursor(), an invalid rowOneIdx causes an IndexError before the intended validation is triggered e.g.

render_text(None, "hello", (10, 0))

raises IndexError: list index out of range instead of ValueError: Invalid row

given that cursor positions are likely derived from LLM-generated actions, invalid row indices are realistically possible and should be defensively handled at the render layer.

let me know if it was an oversight or am i missing something,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions