pi-vim 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +7 -13
  2. package/index.ts +9 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -30,26 +30,20 @@ Clipboard write mirroring is controlled by `piVim.clipboardMirror`:
30
30
  | `yank` | Mirror yanks only; deletes/changes update only pi-vim's internal register |
31
31
  | `never` | Never mirror register writes to the OS clipboard |
32
32
 
33
- The setting controls write mirroring only. `p` / `P` keep the paste policy documented below.
33
+ The setting controls which local register writes cross the OS clipboard boundary. `p` / `P` keep non-mirrored writes local.
34
34
 
35
35
  ## wrapping pi-vim
36
36
 
37
- Supported: `pi-vim` first, `@jordyvd/pi-image-attachments` second. pi-vim does not call `ctx.ui.getEditorComponent()`; the wrapper does. Inverse order unsupported.
37
+ Supported: `pi-vim` first, `@jordyvd/pi-image-attachments` second. pi-vim does not wrap previous editors; wrappers decorate in place or forward the CustomEditor surface: lifecycle (`handleInput`, `render`, `invalidate`), text (`getText`, `setText`, `insertTextAtCursor`, `getExpandedText`), callbacks, `actionHandlers`, flags, reads (`getLines`, `getCursor`, `getMode()`). Inverse order, insert delegates, and generic composition are unsupported.
38
38
 
39
- Wrappers must decorate in place or forward unintercepted surface: lifecycle (`handleInput`, `render`, `invalidate`), text (`getText`, `setText`, `insertTextAtCursor`, `getExpandedText`), callbacks (`onSubmit`, `onChange`, `onEscape`, `onCtrlD`, `onPasteImage`, `onExtensionShortcut`), `actionHandlers`, flags (`focused`, `disableSubmit`), reads (`getLines`, `getCursor`, `getMode()`).
40
-
41
- #18/#21 delegation is not adopted: no previous-extension wrapping, insert delegate, or generic composition layer.
42
-
43
- Manual smoke. If raw `-e` cannot resolve Pi peer packages, run `npm install --ignore-scripts --package-lock=false` in the image checkout.
39
+ Smoke:
44
40
 
45
41
  ```bash
46
- # repo root
47
42
  pi -e ./index.ts -e ../pi-image-attachments/index.ts
48
- # this worktree
49
43
  pi -e ./index.ts -e ../../../pi-image-attachments/index.ts
50
44
  ```
51
45
 
52
- Check: insert text; add/paste image path; see `[Image #1]` widget; submit text+image stripped; switch INSERT/NORMAL modes.
46
+ Check: insert text; add/paste image path; see `[Image #1]`; submit text+image stripped; switch INSERT/NORMAL.
53
47
 
54
48
  ## contributor setup
55
49
 
@@ -297,8 +291,7 @@ implemented and cancel the pending operator. Linewise counted yank (`{count}yy`,
297
291
  | `{count}p` | Put `{count}` times after cursor |
298
292
  | `{count}P` | Put `{count}` times before cursor |
299
293
 
300
- Put reads the OS clipboard first, falling back to the internal unnamed-register shadow on slow read.
301
- Paste text ending in `\n` is treated as line-wise.
294
+ Put reads the OS clipboard first unless the last local register write was not mirrored. Paste text ending in `\n` is line-wise.
302
295
 
303
296
  ---
304
297
 
@@ -320,7 +313,8 @@ Paste text ending in `\n` is treated as line-wise.
320
313
  - `piVim.clipboardMirror = "yank"` mirrors yanks only; deletes and changes update only pi-vim's internal shadow.
321
314
  - `piVim.clipboardMirror = "never"` disables write mirroring while keeping internal register writes synchronous.
322
315
  - Rapid mirrored writes coalesce: only the latest pending value is guaranteed to be mirrored.
323
- - `p` / `P` read the OS clipboard first, falling back to the shadow on read failure/timeout.
316
+ - `p` / `P` read the OS clipboard first when no local write was skipped by policy, falling back to the shadow on read failure/timeout.
317
+ - If policy skipped the last local write, `p` / `P` use the shadow so delete/yank → put works without touching the OS clipboard.
324
318
  - While a mirror is in flight, `p` / `P` use the shadow so immediate yank/delete → put stays ordered.
325
319
  - Pi owns the terminal clipboard backends; on Wayland external state may lag while the shadow stays authoritative for immediate puts.
326
320
 
package/index.ts CHANGED
@@ -554,6 +554,7 @@ export class ModalEditor extends CustomEditor {
554
554
 
555
555
  // Unnamed register
556
556
  private unnamedRegister: string = "";
557
+ private preferRegisterForPut = false;
557
558
  private clipboardMirrorPolicy: ClipboardMirrorPolicy = DEFAULT_CLIPBOARD_MIRROR_POLICY;
558
559
  private readonly clipboardMirror = new ClipboardMirror(writeClipboardInChildProcess);
559
560
  private clipboardReadFn: ClipboardReadFn = readClipboardInChildProcess;
@@ -592,7 +593,10 @@ export class ModalEditor extends CustomEditor {
592
593
  setQuitFn(fn: () => void): void { this.quitFn = fn; }
593
594
  setNotifyFn(fn: (message: string) => void): void { this.notifyFn = fn; }
594
595
  getRegister(): string { return this.unnamedRegister; }
595
- setRegister(text: string): void { this.unnamedRegister = text; }
596
+ setRegister(text: string): void {
597
+ this.unnamedRegister = text;
598
+ this.preferRegisterForPut = false;
599
+ }
596
600
  getMode(): Mode { return this.mode; }
597
601
  getText(): string { return this.getLines().join("\n"); }
598
602
 
@@ -2362,8 +2366,9 @@ export class ModalEditor extends CustomEditor {
2362
2366
 
2363
2367
  private writeToRegister(text: string, source: RegisterWriteSource = "mutation"): void {
2364
2368
  this.unnamedRegister = text;
2365
- if (!text) return;
2366
- if (!this.shouldMirrorRegisterWrite(source)) return;
2369
+ const shouldMirror = text !== "" && this.shouldMirrorRegisterWrite(source);
2370
+ this.preferRegisterForPut = text !== "" && !shouldMirror;
2371
+ if (!shouldMirror) return;
2367
2372
 
2368
2373
  this.clipboardMirror.mirror(text);
2369
2374
  }
@@ -2845,7 +2850,7 @@ export class ModalEditor extends CustomEditor {
2845
2850
  private static readonly PUT_SIZE_LIMIT = 512 * 1024; // 512 KB safety cap
2846
2851
 
2847
2852
  private getPasteRegisterText(): string {
2848
- if (this.clipboardMirror.hasPendingWrite()) {
2853
+ if (this.preferRegisterForPut || this.clipboardMirror.hasPendingWrite()) {
2849
2854
  return this.unnamedRegister;
2850
2855
  }
2851
2856
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-vim",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Vim-style modal editing for Pi's TUI editor",
5
5
  "type": "module",
6
6
  "keywords": [