Skip to content

Clamp negative rows when translating document positions - #2098

Open
oodadoudou wants to merge 1 commit into
prompt-toolkit:mainfrom
oodadoudou:codex/clamp-negative-document-rows
Open

oodadoudou wants to merge 1 commit into
prompt-toolkit:mainfrom
oodadoudou:codex/clamp-negative-document-rows

Conversation

@oodadoudou

Copy link
Copy Markdown

Negative rows currently count backwards from the end of the document. Clamp them before looking up the line, as documented: for Document("one\ntwo\nthree"), translating (-1, 0) now returns 0 instead of 8.

The regression covers negative rows, column bounds, empty text and a trailing newline. All 167 tests pass.

Fixes #2097.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document.translate_row_col_to_index does not clamp negative rows to zero

1 participant