-
Notifications
You must be signed in to change notification settings - Fork 1.4k
termio: report color scheme synchronously #9705
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: main
Are you sure you want to change the base?
Conversation
|
This is my first try at contributing back to Ghostty, please let me know if I missed something prior to implementation. Thanks to the awesome issue description it was relatively straightforward to resolve it. I've tested the changes on my machine and running the commands from the issue multiple times resulted in always the same order of the responses. I've tried to attach an execution log but GitHub mangles with the escape codes in the code block. |
mitchellh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems this doesn't fully faithfully convert this, since we're ignoring the mode flag in some cases where we previously didn't.
I don't have a problem with copying the conditional state.
|
Thanks for the review, just to clarify because I'm not that familiar. By mode flag do you refer to the force argument previously being present? I've removed it in places where it was always used with false and forcefully send the mode flag unconditionally in cases where it should by possible async changes (in the Surface.zig). |
|
I'll re-review later, but it looks like both |
|
That's right I've made the assumption that in case it's requested in termio it always needs to be responded to, cause if that code is reached the request was explicitly driven by request. But I could be mistaken here, I will think about it once again. |
9a9a078 to
5018823
Compare
|
You were right, I've found two instances where I mistakenly changed the behavior. I've reintroduced the force flag and updated the callers.
Update: |
eeffdc8 to
c616b93
Compare
c616b93 to
6d20132
Compare
mitchellh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes, and sorry for the continued slow review. I've suggested one more thing. I'm working my way through PR backlogs now, got down 30 PRs the last week. 😄
| if (!self.renderer_state.terminal.modes.get(.report_color_scheme)) { | ||
| return; | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of duplicating this logic, we should add a new termio message so it's all sent from the same thread. Writes like this are already not synchronous ANYWAYS so that should be fine.
The reporting of color scheme was handled asynchronously by queuing a handler in the surface. This could lead to race conditions where the DSR is reported after subsequent VT sequences. Fixes ghostty-org#5922
6d20132 to
c6870ac
Compare
|
Now I was out for vacation, sorry for the delay on my side. I hope I understood your suggestion and implemented in the way you envisioned. PTAL and let me know if things needs to be updated. |
| pub const WriteReq = MessageData(u8, 38); | ||
|
|
||
| /// Request a color scheme report is sent to the pty. | ||
| color_scheme_report: struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renaming from verb-noun to noun-verb seems unnecessary, and a bit counter to existing practice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've named it according to
Line 321 in 1c2db85
| .size_report => |v| try io.sizeReport(data, v), |
I'm happy to rename it to whatever is preferred.
The reporting of color scheme was handled asynchronously by queuing a handler in the surface. This could lead to race conditions where the DSR is reported after subsequent VT sequences.
Fixes #5922