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

Cursor disappears when adding space to full line #1112

Closed
TannersAndRodents opened this issue Sep 11, 2022 · 3 comments · Fixed by #1113
Closed

Cursor disappears when adding space to full line #1112

TannersAndRodents opened this issue Sep 11, 2022 · 3 comments · Fixed by #1113
Assignees
Labels
bug Issue: Something isn't working

Comments

@TannersAndRodents
Copy link

When a line in the document editor is full (adding another character would break the last word into a new line), it is possible for the text cursor to disappear, when one (or multiple) space is added at the end. To reproduce, just write a few words and hit space until the cursor vanishes.

Resizing the document editor doesn't help, but any non-space character will bring the cursor back. However, the spaces will still be ignored by the editor preference "Show tabs and spaces".

@TannersAndRodents TannersAndRodents added the bug Issue: Something isn't working label Sep 11, 2022
@vkbo vkbo added this to the Release 1.7 RC 1 milestone Sep 12, 2022
@vkbo
Copy link
Owner

vkbo commented Sep 12, 2022

Hi, and thanks for reporting.

For your first issue, this is not a bug. The editor doesn't wrap lines ending in multiple spaces, so the cursor simply just moves out of the frame and under the text margin. All I can do is add an option that makes the editor window start scrolling horizontally to follow the cursor, which may actually be more user-friendly. The result is that the left margin of the text will be clipped instead.

For your second point about the spaces being ignored by "Show tabs and spaces". This is intended behaviour, like it or not. This is done by the text rendering component of the editor widget on the Qt library side of things. I cannot change this behaviour on my end. It is the same underlying cause as in #1043. When the text is rendered on your screen, each line is made from a text box with a width defined by the width of the text without trailing spaces. Hence, added decoration to those spaces will not be rendered.

I'll leave this open so that I can look into adding the auto-scrolling feature for the cursor.

See also QTBUG-9742.

@vkbo
Copy link
Owner

vkbo commented Sep 14, 2022

Turns out the cursor is clipped in cases where the text (spaces or any other char) reaches exactly the right hand margin of the document editor. Since the cursor is positioned to the right of the edge, it disappears due to the document margin being set to zero. The margin visible in the editor is actually a margin of the viewport the document sits in, not the actual document.

I've fixed the issue (I hope) by setting the document margin to the same value as the cursor's width, and subtract the same amount from the viewport margin. Now, the cursor will stop moving when it reaches the edge, and still be visible.

It's too small a fix to do a patch release on 1.6.x, so I'm including it in the upcoming 1.7 release.

@vkbo vkbo added this to Triage in Bug Tracker 1.x via automation Sep 14, 2022
@vkbo vkbo moved this from Triage to Closed in Bug Tracker 1.x Sep 14, 2022
@TannersAndRodents
Copy link
Author

Thanks a lot! I cloned the repo and it seems to work like a charm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue: Something isn't working
Projects
No open projects
Bug Tracker 1.x
  
Closed
Development

Successfully merging a pull request may close this issue.

2 participants