Skip to content

fix: close osc8 exitUrl correctly#792

Merged
gdamore merged 1 commit intogdamore:mainfrom
phanen:fix-exit-osc8
Jul 13, 2025
Merged

fix: close osc8 exitUrl correctly#792
gdamore merged 1 commit intogdamore:mainfrom
phanen:fix-exit-osc8

Conversation

@phanen
Copy link
Copy Markdown
Contributor

@phanen phanen commented Mar 24, 2025

Trying to fix emiting redundant osc8 (which I found in lazygit jesseduffield/lazygit#4421).

Sorry if I misunderstand something (since this pattern repeat twice... both in linux and windows), but I think the "exiturl" part should be closed immediately?

@gdamore
Copy link
Copy Markdown
Owner

gdamore commented Jul 10, 2025

The intention here was to emit only a single OSC spanning multiple cells... we only "close" it when we reach the end of the URL.

I don't think this change is correct.

Comment thread tscreen.go
Copy link
Copy Markdown
Owner

@gdamore gdamore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't right... can you explain what you're trying to solve?

@gdamore
Copy link
Copy Markdown
Owner

gdamore commented Jul 10, 2025

I looked at the downstream bug. I think the analysis there is probably incorrect.

@phanen
Copy link
Copy Markdown
Contributor Author

phanen commented Jul 10, 2025

lazygit never use url so it's always "". (jesseduffield/lazygit#4421 (comment))

So the problem here is exitUrl should only be emited when we have enterUrl.

Comment thread tscreen.go Outdated
@phanen phanen force-pushed the fix-exit-osc8 branch 3 times, most recently from defdab8 to ea78599 Compare July 11, 2025 16:29
@phanen
Copy link
Copy Markdown
Contributor Author

phanen commented Jul 11, 2025

Done now (forgot to rebase before)

@phanen
Copy link
Copy Markdown
Contributor Author

phanen commented Jul 11, 2025

Wait. the logic in windows looks a bit different. I'll look it again

Co-authored-by: stk <stk@ableton.com>
@phanen
Copy link
Copy Markdown
Contributor Author

phanen commented Jul 11, 2025

Ok I'm not sure what happened here, on style change: it write last style rather than the current one.

tcell/console_win.go

Lines 1052 to 1056 in 17ca208

if !dirty || style != lstyle {
// write out any data queued thus far
// because we are going to skip over some
// cells, or because we need to change styles
s.writeString(lx, ly, lstyle, vtBuf, wcs)

while in tscreen.go it write current style (not the last style).

~So if this is a typo I can correct it but I would guess it's probably not again...
~

EDIT: it's not a typo according the comment.
I cannot figure out a way without using a urlOpen variable. (Otherwise a "last of last style"??

@gdamore
Copy link
Copy Markdown
Owner

gdamore commented Jul 13, 2025

The idea of the "lastStyle" was to ensure that we flush any unwritten changes when changing style. The whole idea is to reduce system call overhead by batching.

@gdamore gdamore merged commit cba92be into gdamore:main Jul 13, 2025
@stefanhaller
Copy link
Copy Markdown

What happened to the windows implementation? I'm surprised that this got merged when it still doesn't work on Windows.

@gdamore It looks like the Windows implementation is sufficiently different from tScreen that the same approach of using curstyle isn't easily possible. I briefly looked into making the cScreen implementation more similar to tScreen in this regard, but there are too many things in the code that I don't understand, so I didn't feel comfortable suggesting that.

It looks like for Windows we do have to go with the urlOpen variable approach, unless we totally want to refactor the logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants