Typing any character after a character like 'ä' in a TextInput makes program panic
It seems that any character like 'ä' (I also tested 'å' and 'ö', should be applicable to any character that is formed from combining 2 characters (e.g. '¨' + 'a' = 'ä', nordic keyboards have keys for 'ä', 'ö', and 'å' directly) causes the program to panic with the following backtrace:
debug(vaxis): resizing screen: width=188 height=59
info(vaxis): kitty keyboard capability detected
thread 707608 panic: index out of bounds: index 30, len 0
/home/kirottu/.cache/zig/p/1220f3e29bc40856bfc06e0ee133f814b0011c76de987d8a6a458c2f34d82708899a/src/GraphemeData.zig:77:48: 0x1478967 in gbp (dotvc)
return @enumFromInt(self.s3[self.s2[self.s1[cp >> 8] + (cp & 0xff)]] >> 4);
^
/home/kirottu/.cache/zig/p/1220f3e29bc40856bfc06e0ee133f814b0011c76de987d8a6a458c2f34d82708899a/src/grapheme.zig:209:34: 0x13407f4 in graphemeBreak (dotvc)
const cp1_gbp_prop = data.gbp(cp1);
^
/home/kirottu/.cache/zig/p/1220f3e29bc40856bfc06e0ee133f814b0011c76de987d8a6a458c2f34d82708899a/src/grapheme.zig:57:26: 0x12c34f8 in next (dotvc)
if (graphemeBreak(
^
/home/kirottu/.cache/zig/p/1220ac04f500bd0ef76e24ee93dda2c46718db26eb2bceb2acb5e3694f98745ef8c1/src/widgets/TextInput.zig:127:27: 0x134b7be in graphemesBeforeCursor (dotvc)
while (first_iter.next()) |_| {
^
/home/kirottu/.cache/zig/p/1220ac04f500bd0ef76e24ee93dda2c46718db26eb2bceb2acb5e3694f98745ef8c1/src/widgets/TextInput.zig:138:50: 0x12d3cc8 in drawWithStyle (dotvc)
const cursor_idx = self.graphemesBeforeCursor();
^
/home/kirottu/.cache/zig/p/1220ac04f500bd0ef76e24ee93dda2c46718db26eb2bceb2acb5e3694f98745ef8c1/src/widgets/TextInput.zig:134:23: 0x127a90c in draw (dotvc)
self.drawWithStyle(win, .{});
^
/home/kirottu/Projects/dotvc/src/client/search.zig:268:33: 0x1278aa7 in run (dotvc)
self.text_input.draw(input_child);
^
/home/kirottu/Projects/dotvc/src/client/client.zig:61:22: 0x128915b in run (dotvc)
try state.run();
^
/home/kirottu/Projects/dotvc/src/main.zig:101:23: 0x128ac2c in main (dotvc)
try client.run(allocator, matches, config_path);
^
/home/kirottu/.zvm/master/lib/std/start.zig:656:37: 0x128be3b in main (dotvc)
const result = root.main() catch |err| {
^
???:?:?: 0x7f9764b49487 in ??? (libc.so.6)
Unwind information for `libc.so.6:0x7f9764b49487` was not available, trace may be incomplete
???:?:?: 0x7f9764b4954b in ??? (libc.so.6)
???:?:?: 0x120cb24 in ??? (???)
run
+- run dotvc failure
error: the following command terminated unexpectedly:
/home/kirottu/Projects/dotvc/zig-out/bin/dotvc search
Build Summary: 10/12 steps succeeded; 1 failed
run transitive failure
+- run dotvc failure
error: the following build command failed with exit code 1:
/home/kirottu/Projects/dotvc/.zig-cache/o/0c829b2ad5e6e5dd9db94669c100271b/build /home/kirottu/.zvm/master/zig /home/kirottu/.zvm/master/lib /home/kirottu/Projects/dotvc /home/kirottu/Projects/dotvc/.zig-cache /home/kirottu/.cache/zig --seed 0xa3401bc0 -Z3f598fedf7048e3f run -- search
What terminal are you using? I am wondering what the actual encoded key sequence is that libvaxis is reading...but that will depend on if you have a terminal with kitty keyboard or not.
To elaborate - it seems like we are ending up with bad utf8 in the TextInput.
I'm using Alacritty and from a quick lookup it would seem Alacritty does have support for it (A PR was merged for v0.13) although some of the later releases have changed the functionality a bit as per the changelogs.
Could you do the following:
printf "\x1b[29u" && cat -v and then press the keys that you are pressing to lead to the panic (including the ones with combining characters)? Also send the version of Alacritty you have.
Any chance you could try that command?
I also use ä and was curious if it would still crash. However, I couldn't reproduce the crash (might be fixed).
Tried with ghostty 1.1.3 and alacritty 0.15.1
When executing printf "\x1b[29u" && cat -v, then typing ä and pressing enter, it returns M-CM-$.
When executing
printf "\x1b[29u" && cat -v, then typing ä and pressing enter, it returnsM-CM-$
I've read this every day for the last 3 days and can't figure out what M-CM-$ is. Do both ghostty and alacritty print this? And am I to interpret this this bug no longer exists...?
I've read this every day for the last 3 days and can't figure out what
M-CM-$is. Do both ghostty and alacritty print this? And am I to interpret this this bug no longer exists...?
I'm not sure, since I couldn't reproduce it might be fixed. Maybe close and @Kirottu reopens if it happens again?
I didn't know how to interpret that either. I just ran the command you posted, then typed ä, then pressed Enter and saw M-CM-$ being returned in the line below... Both in ghostty and alacritty.
Closing for now. if this issue crops up again, we can open a new issue.