-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Unwrap terminal buffer #8365
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
base: master
Are you sure you want to change the base?
Unwrap terminal buffer #8365
Conversation
This comment has been minimized.
This comment has been minimized.
Cc @leonerd |
32f0c86
to
bb0cbd6
Compare
Because MSVC 10 doesn't support C99 style variable declaration. |
Codecov Report
@@ Coverage Diff @@
## master #8365 +/- ##
==========================================
+ Coverage 81.80% 82.28% +0.47%
==========================================
Files 162 154 -8
Lines 188049 171344 -16705
Branches 42753 39250 -3503
==========================================
- Hits 153837 140990 -12847
+ Misses 21696 17224 -4472
- Partials 12516 13130 +614
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
cafce6f
to
8c917d3
Compare
Just FYI: I was pinged on this PR but I'm not intending to look into it all that much. vim's forked copy of libvterm has continued to diverge from my upstream copy to the point that it isn't easy to synchronise these things in again. In any case this particular development has happened entirely without my thoughts or input on the matter, and is somewhat different to the still in-progress work I have in a similar direction upstream. Overall if youfolks want to try to synchronise these things back together again we need to do a much better job of coördinating things; otherwise I suspect you're on your own at this point. |
8c917d3
to
a957733
Compare
TBH @leonerd this PR modifies one callback from libvterm, the rest are just modifications to vim. There’s no real functional changes to libvterm: text reflowing is not implemented in libvterm in this PR − only in the vim buffer. The vim/src/libvterm/include/vterm.h Line 492 in 7d013b6
If anyone suggests a better way I’m happy to go with it:
|
@leonerd You can easily subscribe to Vim changes and filter on "libvterm" to see what changes are made in the Vim copy of libvterm code. |
a957733
to
3db2e6a
Compare
I did the missing case for Windows wide-chars, but this approach seems somwhat doomed I’m afraid due to unforeseen interactions with
The ways this manifests in vim is that lines are incorrectly joined (joins are shift by 1) when the continuation lines are offscreen. |
So we either have scrolling broken or the automatic resize? Especially in TermDebug sessions with GDB often having to output longer content it would be very nice if making the gdb window wider would also show the content instead of multiple hard-broken lines and a lot of spaces. |
At least that’s the issue with this attempt of implementing reflow @GitMensch. I’m sure there could be another way, but likely not without some input from people who have a better understanding of libvterm and/or vim’s |
a2fd198
to
fb93459
Compare
After some more debugging I’ve managed to actually make this work as expected. Just to reiterate, this doesn’t handle resizing the terminal when it’s running, just displaying the terminal contents without undesired linebreaks when in normal buffer mode (and all that entails, see discussion above). I’ve opened a discussion on the libvterm launchpad to see whether this would cause some additional divergence, or if we can keep that as low as possible. |
Sounds like this will address #5769 as well if I'm not mistaken. |
I haven’t heard back from @leonerd yet, but I’ve been able to have a look at his work on reflowing in libvterm and the changes proposed there seem perfectly complementary to those in this PR. In the mean time, I’ve setup some mirrors so you can visualize the libvterm reflow changes etc. |
Hi @Cimbali what are you waiting for from me? |
Just your input on the changes affecting libvterm really (of which I also provided a rebased version on the upstream codebase on launchpad). There’s a callback change, so it’s a pretty significant change. However I believe it fits in well with your work in progress on reflowing. Roughly, it allows history to be reflowed, so in this instance the vim buffer. It will also allow to pull lines with proper length from history with sb_popline after resize (or during resize if adding more rows to the window). If you think these changes are good and you’re likely to integrate them into your reflow work, then I suppose it’s low risk to merge them here. If you’d prefer another way of doing, I can look into it. And if you’d think you’d rather not do these changes in ilbvterm at all, it’s up to @brammool to arbitrate the risk of diverging codebases further versus the added functionality. |
I've added comment on the launchpad issue; copied here:
|
fb93459
to
f427c3e
Compare
Hi @leonerd, just a ping to notify you that I replied on launchpad last month and added a test. It’s also in this PR. The changeset is really small, just adding a value to a callback. Please let us know if you plan on reviewing it. |
@Cimbali I tried the patch and it mostly works great. However there is a problem with very long lines. Try |
Thanks for testing @noscript, I'll look into it. Do you maybe have a screenshot? |
@Cimbali Any updates? Finishing this would be so helpful for debugging... |
The output of seq -s + 30 on 30 columns is: ``` 1+2+3+4+5+6+7+8+9+10+11+12+13+ 14+15+16+17+18+19-20+21+22+23+ 24+25+26+27+28+29+30 ``` This test checks there are at least 2 lines for the terminal and only one in the buffer.
Pass the info to add_scrollback_line_to_buffer() to correctly append terminal lines to the last line or to a new line. Handle postponed callback, which requires storing the continuation info in the line struct.
Due to continuation, a buffer line can correspond to several VTerm lines. Make sure we remove the correct amount.
Instead of row number shifted by number of scrolled back rows.
For example after changes in a terminal buffer
And thus comaprable to STRLEN which returns size_t
- comment - fix width during test - do not rely on seq options being available everywhere - use a vertical split rather than columns as suggested - wait for non-empty first line as other tests do, instead of finished status - compare line contents instead of line numbers in case of echoing
This PR has never been about reflow in an active terminal session, but about reflowing terminal contents once passed on to vim. We’re still stuck at the same point @simlei:
There’s just no way to reflow without knowing which line breaks can be moved and which can’t. So far (1) seemed the preferred option, with @leonerd stating in this thread he preferred implementing his own version of this requirement over the patches I sent, to which I replied I’ll happily rebase on that work when made available. That was 20 months ago. I think the correct way forward is to set a deadline by which we fall back to option (2) if this current reminder (and any potential future ones) keep remaining unaddressed. |
I'm sure I could look into adding something in libvterm for that then, yes. |
Right - thinking out loud this is slightly nontrivial. If there were no API compat guaratnees at all, then I could simply add a I'm in a dilemma of
It leads to a messier API but it's only temporary, so I'm going to go for option 2. |
Let me know if I can help, however I have very limited knowledge of the vim
codebase.
…On Tue, 16 Jul 2024, 14:14 Paul Evans ***@***.***> wrote:
Right - thinking out loud this is slightly nontrivial. If there were no
API compat guaratnees at all, then I could simply add a VTermLineInfo *
parameter to sb_pushline and all would be well. But I can't because that
would break older code.
I'm in a dilemma of
1. Major version bump, up to v0.4, just for this one one change. If
I'm going to bump that number I feel I should take the opportunity to
change a lot more stuff while I'm there and that makes it take a lot longer.
2. Temporarily add an API to set a different callback that takes that
extra argument, as a workaround for not changing it currently. You'll have
to call a different function to set the pushline callback with a different
signature.
It leads to a messier API but it's only temporary, so I'm going to go for
option 2.
—
Reply to this email directly, view it on GitHub
<#8365 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHP225FSSUTWI3PSE2ZTSTZMUFDBAVCNFSM46RA3CN2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMRTGA3TGOJVG42Q>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Ah this is all in libvterm, it's really not directly vim-related code at all. |
Right then. Took me a while to remember to getting around to do it, but this is now done in latest source on bzr. What would be a good way to deliver this for your use? I'd like you to try it out a bit first before I call it the official 0.3.4 version tarball, but I could pack you a pre-release version, or make a .diff out of the relevant commits... or something else? |
Thanks a lot @leonerd ! I’ve fetch the commits from bazaar and am playing around with it. It seems to work well as a drop-in replacement for what I had written, but I need to do some further testing. |
ef4172b
to
ee0a955
Compare
I’ve confirmed this doesn’t work on Windows for some reason. Will have to get my hands on an appropriate setup to build where I can investigate properly why that is (appveyor rdp is a fallback but a bit too limited at this stage). I can’t reproduce the linux uchar test issue/flakiness however. |
I have a Windows PC and can help with testing. Can get any build to work in
wsl
…On Thu, 25 Jul 2024, 17:10 Cimbali ***@***.***> wrote:
I’ve confirmed this doesn’t work on Windows for some reason. Will have to
get my hands on an appropriate setup to build where I can investigate
properly why that is (appveyor rdp is a fallback but a bit too limited at
this stage).
I can’t reproduce the linux uchar test issue/flakiness however.
—
Reply to this email directly, view it on GitHub
<#8365 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHP222XHT3Y7DZGRUC4G4DZOEIP7AVCNFSM46RA3CN2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMRVGA3DGMBQG4ZA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I'd like to again offer my support in debugging this issue. Have a windows PC. gdb noob though; instructions required. |
Thanks @simlei. I think good first steps would be compiling and running the unit tests, to reproduce. Then figuring out why the failing unit test fails. Probably adding stderr printfs in |
Ok, will get a setup running on the weekend and ping you back when I get
stumped ok?
…On Tue, Oct 29, 2024 at 11:34 AM Cimbali ***@***.***> wrote:
Thanks @simlei <https://github.com/simlei>. I think good first steps
would be compiling and running the unit tests, to reproduce. Then figuring
out why the failing unit test fails. Probably adding stderr printfs in
handle_pushline and add_scrollback_line_to_buffer and redirecting that to
a log with vim 2> log to understand what’s going on, whether continuation
flags are correctly received, if so why pasting lines together doesn’t
work, and so on.
—
Reply to this email directly, view it on GitHub
<#8365 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHP223VGNSJZGFEGC6OUZDZ55QEHAVCNFSM46RA3CN2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TENBUGM4DIMRVGIYQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@Cimbali Can you give an update on the current state of this PR? Also, is there any way to assist you? I would be happy to help :) |
I have previously offered to have a look too but ultimately have not found
the time yet. However during 10-15 March this year might be able to
…On Tue, 11 Feb 2025, 14:41 Lucas Pütz ***@***.***> wrote:
@Cimbali <https://github.com/Cimbali> Can you give an update on the
current state of this PR?
Also, is there any way to assist you? I would be happy to help :)
—
Reply to this email directly, view it on GitHub
<#8365 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHP225SQDWBZWA62KNIIXL2PH4XJAVCNFSM46RA3CN2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TENRVGA4DMMJUGU2A>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
677b216
to
8e6c19f
Compare
8e6c19f
to
6d96c4d
Compare
This PR attempts to fix #2865 by removing newlines marked as « continuation » line feeds from the terminal output, when pushing these lines to the buffer.
This allows e.g. to open a file with
gf
when the file name is long and split across several lines. Also nice visually because the wrapping of broken lines is uglyThe good:
The bad:
add_scrollback_line_to_buffer()
: Isml_replace
the correct approach ?sb_pushline
callback ? It seems to be a minimal change and I’ve checked other occurrences of this callback.I'd like some feedback before continuing to work on this.
Finally, I’ve added the
continuation
info to the scrollback lines, which may not be 100% necessary (there could be a work-around) at this time − however I believe this will be useful to « reflow » lines, that is move the continuation line breaks on window resizes. See discussion in #2865.Terminal mode: long line causing « continuation » line feeds (same for both vim version):

Switching to normal mode (current vim master), long output line is artifically split, causes problems to select as 1 word and messy display:

Switching to normal mode (vim built from this PR), long output line appears as a single line (see line numbers), line split is moved due to gutter size (now in
53
instead of after54
) single word split across displayed lines is really a single word: