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

Soft wrap can be empty #6765

Closed
vwkd opened this issue Apr 15, 2023 · 5 comments
Closed

Soft wrap can be empty #6765

vwkd opened this issue Apr 15, 2023 · 5 comments
Labels
C-bug Category: This is a bug

Comments

@vwkd
Copy link
Contributor

vwkd commented Apr 15, 2023

Summary

I'm occassionally experiencing an empty soft wrap. I suspect this happens due to the trailing newline character being treated as a "normal character" that is wrapped when the line width happens to be just right.

Here's a screenshot. Note, there is no trailing whitespace in the line.

empty-soft-wrap

Reproduction Steps

  1. Open helix with soft wrap enabled
  2. Fill text until the end of the line
  3. If the issue doesn't occur, change the terminal width and/or zoom and repeat from 2.

Note, it needs a bit of fiddling around with terminal width and/or zoom to hit the right line width but it happens often enough for me to hit quickly.

Here's a screen recording. Note, there is no trailing whitespace in the line, just inserting and deleting "k".

helix-bug.mov

Helix log

No response

Platform

macOS

Terminal Emulator

iTerm2

Helix Version

helix 23.03 (3cf0372)

@vwkd vwkd added the C-bug Category: This is a bug label Apr 15, 2023
@pascalkuthe
Copy link
Member

This is intentional. The newline character is always selectable in helix. What you are seeing is the newline char being wrapped to the next line. If that wasnt the case the cursor would disappear offscreen when selecting the newline char

@vwkd
Copy link
Contributor Author

vwkd commented Apr 15, 2023

Makes sense. Kind of visually confusing, but I guess it just takes getting used to.

@vwkd vwkd closed this as not planned Won't fix, can't repro, duplicate, stale Apr 15, 2023
@vwkd
Copy link
Contributor Author

vwkd commented Jan 3, 2024

I still believe this is confusing as wrapping the newline character is visually indistinguishable from a blank line apart from the missing line number and a wrap indicator (if non-blank). But despite being aware of it, it continues to fool me every time since it's unintuitive to look at line numbers or wrapping indicators.

Here's the identical screen recording reproduced with the wrap indicator set to blank that matches common text editor UIs. Notice, the only empty line is 4 which looks visually indistinguishable to the wrapped newline character of line 2.

demo.mov

config.toml used:

[editor.soft-wrap]
enable = true
wrap-indicator = ""

Here's the screen recording in VSCode.

vscode.mov

A proposed solution

A simple fix could be to wrap at least the last two characters if the last one is the newline character.

This would still cause the issue if there is trailing whitespace in the line but this is also the behavior of common text editor UIs.

@vwkd vwkd reopened this Jan 3, 2024
@th7mo
Copy link

th7mo commented Jan 13, 2024

I had this issue as well, it happens more than I would think would happen.

I understand this behavior is not a bug and the newline character should be selectable of course. But... I don't think this implementation is desirable for most people.

I find it very confusing however when I use Helix those empty lines (except for the \n char of course) appear as demonstrated by @vwkd and it throws me off when editing text or code.

The soft-wrap feature already wraps an entire word to the next line when it does not fit on the line. Why wouldn't it treat the newline character the same as any other regular character? The newline character is not a word so it should not be wrapped as one. It is more like a . (period) to indicate the end of a sentence.

I propose that the soft-wrap feature treats the newline character not as a whitespace, but as a 'normal character' (or like the . (period) character. This makes the newline character the last character of the last word of the line. The result of this change will let the soft-wrap feature wrap the word with the newline character to a new space, instead of only the newline character.

I hope this will be reconsidered as it would improve the awesome soft-wrap feature even more!

@pascalkuthe
Copy link
Member

none of these special case solutions will be implemented. As I said many times before we will not special case newline characters. Currently the wrapping is pretty simple and essentially just wraps anything that counts as a word character together (as a word) and otherwise, everything as an individual characters (so there is no distinction between a period and a newline character for example). The way this will be improved is generally wrapping all trailing non-word chars with their preceding word as one unit. Duplicate of #6829

@pascalkuthe pascalkuthe closed this as not planned Won't fix, can't repro, duplicate, stale Jan 13, 2024
@helix-editor helix-editor locked and limited conversation to collaborators Jan 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C-bug Category: This is a bug
Projects
None yet
Development

No branches or pull requests

3 participants