kakoune: `` doesn't scroll all the way up with wrapped lines
Hi,
When some lines are wrapped in the current buffer and the main selection is somewhere a few views down the top of the buffer, hitting <pageup>
repeatedly won’t send the selection back to the first line, it will stop a couple lines after (forcing the user to hit gg
).
HTH.
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 8
- Comments: 19 (8 by maintainers)
I have a similar bug, I don’t know if it’s related, but with wrap enable, I can’t use ctrl-u to go up when I want.
Here’s a reproduction:
I’m opening this file in a terminal of size 90x37 Now go to the bottom (gj), and go up from there by pressing multiple times ctrl-u. It will scroll a few lines up and then get stuck at the first wrapped line.
I got tired of this issue, so I (mostly) fixed it with some kakscript. I’ve tested it out by making the viewport of my terminal very narrow (~20 columns) and trying to move around with and without my changes. You can see my approach in this gist. In particular it fixes these movement commands:
gc
gt
gb
vc
vt
vb
<c-f>
<c-b>
<c-u>
(behavior is slightly different than default kakoune, which is also different from vim)<c-d>
(behavior is slightly different than default kakoune, which is also different from vim)The main issues are:
%val{window_range}
, which only reports the visible lines, so blank lines in the viewport aren’t accounted for, resulting in inching toward and away the end of the file.@mawww ideally, this would be handled correctly by kakoune itself. Considering it’s possible to write a (mostly) working approach using kakscript, it seems like kakoune should be able to fix the underlying issues at the C++ layer. Haven’t really dug into the code enough to know exactly how to accomplish that, I’m just deducing by the fact that it’s possible to (mostly) fix the issue with kakscript.
This really is a rather severe issue. Scrolling up using the mouse wheel is borderline impossible; it’s constantly getting stuck. Real annoying.
I wish the cursor could drop out of view, so I could more easily look around the surrounding code without messing up my position.
Possibly related to this is that I’ve noticed that
vc
(center cursor vertically) does not work as expected with wrapped lines: Except at the top of the buffer, the cursor is always repositioned in the lower half of the window, not centrally.I have a similar issue which may have the same cause, so I’ll describe it here.
The issue is that scrolling by page (either by using
<c-f>
/<c-b>
or<pagedown>
/<pageup>
) with line wrapping enabled scrolls by more lines than are visible. For example, if my view spans from line 1 to 48, with many lines wrapping (30 in this case), and I scroll one page down, my view now spans from line 77 to 132, but the new span should have started at line 49! Note that 49 + 30 = 79 (The out-by-2 may be explained by the last line of the original view also spanning several lines, three of which are visible. Maybe this line isn’t counted in the scroll).Just on the severity of this bug: it can cause serious human errors if e.g. I’m trying to read a file, and scrolling through it by page, then I will miss large amounts of the content! I fell victim to this on a number of occasions before I realised that I couldn’t trust the scrolling. But it still gets me.
Reproduced in Kakoune v2020.01.16.