charmbracelet / charmbracelet/x
DECSWT and DECSIN escape sequences are incorrect
- Dominant language
- Go
- Stars
- 314
- Forks
- 94
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 2
Description
### Description
The `DECSWT` function produces an escape sequence starting with `OSC 2;1`, because you're just prepending `1;` on the name passed to the `SetWindowTitle` function, which is an `OSC 2` sequence. See here:
https://github.com/charmbracelet/x/blob/f2fb44ab31459eb3be0bfab80478bd476edee51a/ansi/title.go#L38-L40
But it really should be starting with `OSC 21`, so something more like this:
```cpp
return "\x1b]21;" + name + "\x1b\\"
```
Similarly, the `DECSIN` function produces an escape sequence starting with `OSC 2;L`, because again you're prepending `L;` on the name passed to `SetWindowTitle`. See here:
https://github.com/charmbracelet/x/blob/f2fb44ab31459eb3be0bfab80478bd476edee51a/ansi/title.go#L46-L48
When it should be starting with `OSC 2L`, so something more like this:
```cpp
return "\x1b]2L;" + name + "\x1b\\"
```
Also note that the string terminator is `ST` (which is `ESC \`) and not a `BEL` control (`\x07`). Most modern terminal emulators will accept `BEL` as a terminator, but a real VT520/VT525 will not, so everything following that `BEL` will still be parsed as part of the window title until it receives some form of `ESC`.
You can confirm the correct sequences for these functions in the VT520/VT525 programmer's reference (EK-VT520-RM) found here: https://vt100.net/dec/ek-vt520-rm.pdf
And if you don't have access to a real VT520 or VT525 to test on, I know Windows Terminal at least supports the `DECSWT` sequence. I don't think it supports `DECSIN` though.
### Version
master
### Environment
any
Contributor guide
Research direction
Start in ansi/title.go at the DECSWT and DECSIN definitions linked in the issue. Compare their emitted sequences with the cited VT520/VT525 reference, including the ST terminator. Add focused regression coverage for both functions and run the relevant Go tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100