vis icon indicating copy to clipboard operation
vis copied to clipboard

{ moves back a paragraph too much if cursor at start of line

Open yory8 opened this issue 3 years ago • 6 comments

Given the text:

First paragraph.

Another paragraph.

if cursor is on n of another, using { will bring me to the blank line between the two paragraphs, as expected. But if the cursor is on A of another, I'm brought to First: I'd expect to be brought at the blank line (this is the behavior in vim, and makes more sense/is more useful).

yory8 avatar Jul 22 '22 14:07 yory8

That would indeed make more sense. A patch to fix this would be welcome, or I'll have a look at it myself later.

ninewise avatar Jul 23 '22 08:07 ninewise

thanks. I'd like to give it a try myself, will report back.

ghost avatar Jul 23 '22 10:07 ghost

the bug was introduced in f55312ba. I found that it also appears when using } if you are at EOL.

Reverting the commit fixes the issue completely (with the exception of } when cursor is on the virtual EOL), and doesn't seem to have side-effects.

The rationale for the commit was "ignoring blank lines". I'm not sure what it means: I tried on a test file with several blank lines in a row and the behavior is the same with the commit applied or reverted.

ghost avatar Jul 23 '22 11:07 ghost

I tried on a test file with several blank lines in a row and the behavior is the same with the commit applied or reverted.

What happens when you have a line that only has spaces, tabs or a combination of both between the paragraphs?

casr avatar Aug 01 '22 08:08 casr

@casr

In a situation like this:

First

  <some whitespace>

Second

with the patch reverted:

if the cursor is on S, { moves at the start of line 4, then the start of line 2. IMHO this is correct (it's also how it works in vim).

ghost avatar Aug 05 '22 09:08 ghost

Rather than reverting the whole commit for f55312ba, I have tested a partial revert in bde0a89. My intent with this change is that I think it maintains the point of the original commit while also trying to address this issue.

Edit: I have rebased my fork on the 0.8 tag. Had to force push, so the new commit sha is 16acbd.

jvvv avatar Sep 12 '22 00:09 jvvv