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

[BUG] BufReadFifo hook parameter reports overlapping spans #5255

Open
Screwtapello opened this issue Nov 12, 2024 · 3 comments
Open

[BUG] BufReadFifo hook parameter reports overlapping spans #5255

Screwtapello opened this issue Nov 12, 2024 · 3 comments
Labels

Comments

@Screwtapello
Copy link
Contributor

Version of Kakoune

2024.05.18-132-gdaa7e37e

Reproducer

(echo a; sleep 1; echo b; sleep 1; echo c) |
    kak -n -e 'hook global BufReadFifo .* %{ echo -debug %val{hook_param} }; buffer *debug*'

Outcome

The *debug* buffer reports:

1.1,1.2
1.2,2.2
2.2,3.2

Expectations

The description of BufReadFifo in :doc hooks says:

The hook param contains the range of text that was just inserted, in a format compatible with the select command.

I understand this to mean that the range covers exactly the characters just read from the FIFO. Since a character can't be read more than once from a FIFO, I would expect each character to be covered by exactly one range. However, the character at 1.2 appears in both the first and second events, while the character at 2.2 appears in both the second and third events. Instead, I would expect output like:

1.1,1.2
2.1,2.2
3.1,3.2

Additional information

No response

@krobelus
Copy link
Contributor

Thanks, I had started working on this but didn't have a test, only a suspicion that something is wrong.
Namely the way read_fifo() juggles around the final \n to keep scrolling or not (depending on edit -scroll).
Given that this is so tricky, I hope we can get rid of this newline and simply implement autoscrolling via hooks or options.

@mawww
Copy link
Owner

mawww commented Nov 14, 2024

Its going to be hard to have something as nice as just doing ge on a fifo buffer to have scrolling regardless of how we got into that buffer.

@krobelus
Copy link
Contributor

true; we should maybe also make gj work, which currently only works if the last BufReadFifo had a trailing newline.

a related thing I broke is scrolling in stdin buffers. That should be solvable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants