fix(web): send a typed combining mark as a plain append (#830)

Both editBetween() functions return a pure append as-is before the grapheme split, so a mark typed onto the last letter is not a DEL plus the retyped cluster (zsh would double the base letter).
Drop a redundant setFlushed() in the Tab-completion fallback; detectBufferText() already stores it.
This commit is contained in:
Hadrien Kerlero committed 2026-11-21 16:09:24 +01:00
1 parent e4ac7728ba
commit 414dd51eb2
5 files changed
+44 -1

No files matched your search

+21
View File
@@ -568,6 +568,9 @@ const replayCases: Array<[string, (h: Harness) => void]> = [
expect(h.api.editBetween(`ok${emoji}`, 'ok')).toEqual({ deleted: 1, inserted: '' });
expect(h.api.editBetween(`a${emoji}b`, 'aX')).toEqual({ deleted: 2, inserted: 'X' });
}
// A combining mark or tone typed onto the last letter is a plain append, as on master.
expect(h.api.editBetween('\u0E01', '\u0E01\u0E34')).toEqual({ deleted: 0, inserted: '\u0E34' });
expect(h.api.editBetween('\u0915\u094D', '\u0915\u094D\u0937')).toEqual({ deleted: 0, inserted: '\u0937' });
for (const ch of 'hel') h.type(ch);
h.type('lo');
h.tick();
@@ -959,6 +962,24 @@ const replayCases: Array<[string, (h: Harness) => void]> = [
}
},
],
[
'20c combining marks typed one key at a time are plain appends',
(h) => {
// Thai กิ่ and Hindi क्ष: each keystroke extends the last grapheme cluster.
// Re-typing that cluster would make a code-point line editor (zsh) double the base letter.
for (const word of ['\u0E01\u0E34\u0E48', '\u0915\u094D\u0937']) {
for (const ch of word) h.edit(ch);
h.tick();
h.bytes(Array.from(word));
expect(h.value()).toBe(word);
h.invariant();
while (h.textarea.value) h.backspace();
expect(h.value()).toBe('');
h.tick();
h.clearSent();
}
},
],
[
'21 destroy restoration and stock behavior',
(h) => {
+15
View File
@@ -763,6 +763,19 @@ describe('edit-based sync of the helper textarea (autocorrect replacements)', ()
expect(e.sent.slice(before)).toEqual(['\x7f']);
});
it.each([
['Thai', '\u0E01\u0E34\u0E48'],
['Hindi', '\u0915\u094D\u0937'],
])('types %s combining marks one field state at a time as plain appends', (_name, word) => {
// Each keystroke extends the last grapheme cluster; re-typing that cluster would
// make a code-point line editor (zsh) double the base letter.
const e = editSyncHarness();
e.create(true);
typeKeys(e, word);
expect(e.sent).toEqual(Array.from(word));
expect(e.line()).toBe(word);
});
it.each(MULTI_CODE_POINT_EMOJI)(
'keeps the local-echo draft at ok when the %s is deleted (real overlay)',
(_name, emoji) => {
@@ -825,5 +838,7 @@ describe('edit-based sync of the helper textarea (autocorrect replacements)', ()
expect(editBetween('x😀', 'x')).toEqual({ deleted: 1, inserted: '' });
expect(editBetween('x\u{1F44D}\u{1F3FD}', 'x')).toEqual({ deleted: 1, inserted: '' });
expect(editBetween('', '')).toEqual({ deleted: 0, inserted: '' });
// A mark typed onto the last letter is a plain append, not a DEL and a re-typed cluster.
expect(editBetween('\u0E01', '\u0E01\u0E34')).toEqual({ deleted: 0, inserted: '\u0E34' });
});
});