mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-12-02 16:59:32 +01:00
fix(web): exact iOS caret, review fixes and round-eight items (#830)
Toolbar Enter spends one-shot Ctrl; Backspace finds the last grapheme with Segments.containing(); accessory Shift+Tab keeps the draft like a typed one. Pass the captured session to Compose uploads, voice compose and held CJK drafts; clear Ctrl on deletion-only native edits; path picker clears predictions. Clear xterm dead-key state on native commits; restore a borrowed clipboard field before classifying a key; overlay removeChar spans the pending/flushed boundary. Place the trackpad caret from the overlay layout (getInputAnchor, committedText) or validated xterm cells, hiding when unproven; no end-minus-width arithmetic. Grapheme-aware replay Backspace; docs, README rows, changeset and comment updates.
This commit is contained in:
1 parent
414dd51eb2
commit
cda5d96451
26 files changed
+1072
-170
No files matched your search
@@ -54,7 +54,14 @@ function load({
|
||||
promptResult = true,
|
||||
touch = true,
|
||||
translate,
|
||||
}: { hold?: boolean; promptResult?: boolean; touch?: boolean; translate?: (s: string) => string } = {}) {
|
||||
captureTarget,
|
||||
}: {
|
||||
hold?: boolean;
|
||||
promptResult?: boolean;
|
||||
touch?: boolean;
|
||||
translate?: (s: string) => string;
|
||||
captureTarget?: () => string;
|
||||
} = {}) {
|
||||
const textarea = makeTextarea();
|
||||
const sent: string[] = [];
|
||||
const prompts: string[] = [];
|
||||
@@ -88,6 +95,7 @@ function load({
|
||||
vm.runInContext(src, context, { filename: 'input-cjk.js' });
|
||||
const CjkInput = vm.runInContext('CjkInput', context);
|
||||
CjkInput.init({
|
||||
captureTarget,
|
||||
send: (t: string) => sent.push(t),
|
||||
sendPrompt: (t: string) => {
|
||||
prompts.push(t);
|
||||
@@ -438,6 +446,28 @@ describe('CJK input: Send on Enter', () => {
|
||||
expect(prompts).toEqual([]);
|
||||
});
|
||||
|
||||
it.each([true, false])('a captured target owns the draft across clear (explicit stash: %s)', (stash) => {
|
||||
const { CjkInput, textarea } = load({ captureTarget: () => 'session-b' });
|
||||
CjkInput.restoreDraft('session-a');
|
||||
type(textarea, 'answer for b');
|
||||
if (stash) CjkInput.stashDraft('session-a');
|
||||
CjkInput.clear();
|
||||
CjkInput.restoreDraft('session-a');
|
||||
expect(textarea.value).toBe(PHANTOM);
|
||||
CjkInput.restoreDraft('session-b');
|
||||
expect(textarea.value).toBe(PHANTOM + 'answer for b');
|
||||
});
|
||||
|
||||
it('clear({ discard }) also drops a stash under the captured target', () => {
|
||||
const { CjkInput, textarea } = load({ captureTarget: () => 'session-b' });
|
||||
CjkInput.restoreDraft('session-a');
|
||||
type(textarea, 'answer for b');
|
||||
CjkInput.stashDraft('session-b');
|
||||
CjkInput.clear({ discard: true });
|
||||
CjkInput.restoreDraft('session-b');
|
||||
expect(textarea.value).toBe(PHANTOM);
|
||||
});
|
||||
|
||||
it('a restored draft is held text: Backspace edits it without a DEL', () => {
|
||||
const { CjkInput, textarea, sent } = load();
|
||||
type(textarea, 'ok');
|
||||
|
||||
Reference in new issue
Block a user