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

Extra line break visible after indent when settings wrap, linebreak and breakindent are enabled #13228

Closed
EtiamNullam opened this issue Sep 30, 2023 · 3 comments
Labels

Comments

@EtiamNullam
Copy link

Steps to reproduce

vim -u NONE
:set wrap linebreak breakindent
ia<Esc>
1000.
V>

It looks like this (screenshot comes from neovim, but behavior is the same):

image

As you can see text starts in the second line, but it might as well start in the first one.

Expected behaviour

There should be no line break between whitespaces and the text and it should look just like linebreak is disabled in this case.

It should look like this:

image

Version of Vim

9.0

Environment

Operating system: Windows 10
Terminal: cmder 1.3.21
Shell: cmd, powershell

Logs and stack traces

N/A
@chrisbra
Copy link
Member

Well, the linebreak setting tells Vim to break at the white space. And there is no whitespace once the as start.

@EtiamNullam
Copy link
Author

I'm sorry if I didn't describe the problem well.

I understand that a long word without whitespaces or breakat characters will have to fallback to just wrapping anywhere but that's not the point.

The problem is that a virtual line break appears between a sequence of whitespaces characters and text, even if it won't give any extra space to the text due to breakindent.

Consider this example, where I've set list and listchars to display spaces as +:

image

Cursor is positioned at the last whitespace that precede the long text. The long text begins one column to the right and one row down (which is just one character to the right). It could simply start in the same row. Wrapping in this case is unnecessary.

@chrisbra
Copy link
Member

chrisbra commented Oct 1, 2023

I understand what you are pointing out, but you are seeing correct behaviour. In short what linebreak option does is, it sees some whitespace. Vim then checks, if the next consequitive list of characters (that are not in breakat, so lets just call them letters for now) fits into the rest of the screen line. If it does, those letters will be printed on the line and on the next whitespace or breakat characters, it will perform the check again.

In your case, the rest of following letters does not fit into the rest of the screen line, so it needs to wrap at the space right now. And that's what Vim does. So if you don't want that behaviour, then do not set the linebreak option in the first place.

zeertzjq added a commit to zeertzjq/neovim that referenced this issue Oct 11, 2023
Problem:  linebreak applies for leading whitespace
Solution: only apply linebreak, once we have found non-breakat chars in
          the line

closes: vim/vim#13228
closes: vim/vim#13243

vim/vim@dd75fcf

Co-authored-by: Christian Brabandt <cb@256bit.org>
zeertzjq added a commit to neovim/neovim that referenced this issue Oct 11, 2023
Problem:  linebreak applies for leading whitespace
Solution: only apply linebreak, once we have found non-breakat chars in
          the line

closes: vim/vim#13228
closes: vim/vim#13243

vim/vim@dd75fcf

Co-authored-by: Christian Brabandt <cb@256bit.org>
zeertzjq added a commit to zeertzjq/neovim that referenced this issue Oct 11, 2023
Problem:  linebreak applies for leading whitespace
Solution: only apply linebreak, once we have found non-breakat chars in
          the line

closes: vim/vim#13228
closes: vim/vim#13243

vim/vim@dd75fcf

Co-authored-by: Christian Brabandt <cb@256bit.org>
zeertzjq added a commit to zeertzjq/neovim that referenced this issue Oct 11, 2023
Problem:  linebreak applies for leading whitespace
Solution: only apply linebreak, once we have found non-breakat chars in
          the line

closes: vim/vim#13228
closes: vim/vim#13243

vim/vim@dd75fcf

Co-authored-by: Christian Brabandt <cb@256bit.org>
zeertzjq added a commit to zeertzjq/neovim that referenced this issue Oct 11, 2023
Problem:  linebreak applies for leading whitespace
Solution: only apply linebreak, once we have found non-breakat chars in
          the line

closes: vim/vim#13228
closes: vim/vim#13243

vim/vim@dd75fcf

Co-authored-by: Christian Brabandt <cb@256bit.org>
jaehoonhwang pushed a commit to jaehoonhwang/neovim that referenced this issue Oct 22, 2023
Problem:  linebreak applies for leading whitespace
Solution: only apply linebreak, once we have found non-breakat chars in
          the line

closes: vim/vim#13228
closes: vim/vim#13243

vim/vim@dd75fcf

Co-authored-by: Christian Brabandt <cb@256bit.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants