Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document.end line number is off by one (1-indexed) #4426

Closed
tconbeer opened this issue Apr 18, 2024 · 2 comments · Fixed by #4427
Closed

Document.end line number is off by one (1-indexed) #4426

tconbeer opened this issue Apr 18, 2024 · 2 comments · Fixed by #4427

Comments

@tconbeer
Copy link
Contributor

tconbeer commented Apr 18, 2024

Document.start and Document.end were introduced in #4267

Document.start maps to (0, 0), but Document.end is 1-indexed, with its line number computed from Document.line_count. This is confusing, and breaks with the standard from other functions that return or accept a Location.

For example, this is the current behavior:

>>> from textual.widgets.text_area import Document
>>> doc = Document("foo\nbar")
>>> doc.end
(2, 3)

Expected:

>>> doc.end
(1, 3)

Textual Diagnostics

Versions

Name Value
Textual 0.56.4
Rich 13.7.1

Python

Name Value
Version 3.8.10
Implementation CPython
Compiler GCC 9.3.0
Executable /home/tco/.cache/pypoetry/virtualenvs/textual-textarea-mNcIuqFZ-py3.8/bin/python

Operating System

Name Value
System Linux
Release 5.15.146.1-microsoft-standard-WSL2
Version #1 SMP Thu Jan 11 04:09:03 UTC 2024

Terminal

Name Value
Terminal Application Windows Terminal
TERM xterm-256color
COLORTERM truecolor
FORCE_COLOR Not set
NO_COLOR Not set

Rich Console options

Name Value
size width=120, height=30
legacy_windows False
min_width 1
max_width 120
is_terminal True
encoding utf-8
max_height 30
justify None
overflow None
no_wrap False
highlight None
markup None
height None
Copy link

We found the following entry in the FAQ which you may find helpful:

Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

This is an automated reply, generated by FAQtory

Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

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 a pull request may close this issue.

1 participant