pi-vim 0.3.0 → 0.3.2

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.
package/README.md CHANGED
@@ -354,9 +354,9 @@ These are **explicitly deferred** and not planned for this feature:
354
354
  - `types.ts` — shared types and escape-sequence constants.
355
355
  - `test/` — Node test runner suite; no browser / full runtime required.
356
356
 
357
- Run tests:
357
+ Run checks:
358
358
 
359
359
  ```
360
360
  cd pi-vim
361
- npm test
361
+ npm run check
362
362
  ```
package/index.ts CHANGED
@@ -140,8 +140,8 @@ export class ModalEditor extends CustomEditor {
140
140
 
141
141
  // Unnamed register
142
142
  private unnamedRegister: string = "";
143
- private clipboardFn: (text: string) => void = (text: string) => {
144
- try { copyToClipboard(text); } catch { /* best effort */ }
143
+ private clipboardFn: (text: string) => Promise<void> = async (text: string) => {
144
+ await copyToClipboard(text);
145
145
  };
146
146
 
147
147
  constructor(
@@ -155,7 +155,11 @@ export class ModalEditor extends CustomEditor {
155
155
  }
156
156
 
157
157
  // Test seams
158
- setClipboardFn(fn: (text: string) => void): void { this.clipboardFn = fn; }
158
+ setClipboardFn(fn: (text: string) => unknown): void {
159
+ this.clipboardFn = async (text: string) => {
160
+ await fn(text);
161
+ };
162
+ }
159
163
  getRegister(): string { return this.unnamedRegister; }
160
164
  setRegister(text: string): void { this.unnamedRegister = text; }
161
165
  getMode(): Mode { return this.mode; }
@@ -181,7 +185,7 @@ export class ModalEditor extends CustomEditor {
181
185
  if (!state || !Array.isArray(state.lines)) {
182
186
  throw new Error("Redo restore prerequisite: editor state unavailable");
183
187
  }
184
- return state;
188
+ return state as { lines: string[]; cursorLine?: number; cursorCol?: number };
185
189
  }
186
190
 
187
191
  private restoreSnapshot(snapshot: EditorSnapshot): void {
@@ -1315,7 +1319,7 @@ export class ModalEditor extends CustomEditor {
1315
1319
  }
1316
1320
 
1317
1321
  private moveCursorToFirstNonWhitespace(): void {
1318
- const { line, col } = this.getCurrentLineAndCol();
1322
+ const { line } = this.getCurrentLineAndCol();
1319
1323
  const targetCol = findFirstNonWhitespaceColumn(line);
1320
1324
  this.moveCursorToCol(targetCol);
1321
1325
  }
@@ -1618,7 +1622,8 @@ export class ModalEditor extends CustomEditor {
1618
1622
  private writeToRegister(text: string): void {
1619
1623
  this.unnamedRegister = text;
1620
1624
  if (!text) return;
1621
- this.clipboardFn(text);
1625
+
1626
+ void this.clipboardFn(text).catch(() => {});
1622
1627
  }
1623
1628
 
1624
1629
  private getCurrentLineAndCol(): { line: string; col: number } {
@@ -2008,7 +2013,7 @@ export class ModalEditor extends CustomEditor {
2008
2013
  this.writeToRegister(line.slice(start, end));
2009
2014
  }
2010
2015
 
2011
- private yankRangeByAbsolute(currentAbs: number, targetAbs: number, inclusive: boolean): void {
2016
+ private yankRangeByAbsolute(currentAbs: number, targetAbs: number, inclusive: boolean = false): void {
2012
2017
  const text = this.getText();
2013
2018
  const start = Math.min(currentAbs, targetAbs);
2014
2019
  const rawEnd = Math.max(currentAbs, targetAbs) + (inclusive ? 1 : 0);
package/motions.ts CHANGED
@@ -172,7 +172,7 @@ export function findCharMotionTarget(
172
172
  const tillRepeatOffset = isFirst && isTill && isRepeat ? 1 : 0;
173
173
 
174
174
  if (isForward) {
175
- let nextIndex = currentIndex + 1 + tillRepeatOffset;
175
+ const nextIndex = currentIndex + 1 + tillRepeatOffset;
176
176
  let found = -1;
177
177
  for (let j = nextIndex; j < graphemes.length; j++) {
178
178
  const g = graphemes[j]!;
@@ -187,7 +187,7 @@ export function findCharMotionTarget(
187
187
  if (isFinal) return isTill ? graphemes[found - 1]!.start : graphemes[found]!.start;
188
188
  currentIndex = found;
189
189
  } else {
190
- let nextIndex = currentIndex - 1 - tillRepeatOffset;
190
+ const nextIndex = currentIndex - 1 - tillRepeatOffset;
191
191
  let found = -1;
192
192
  for (let j = nextIndex; j >= 0; j--) {
193
193
  const g = graphemes[j]!;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-vim",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Vim-style modal editing for Pi's TUI editor",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -22,10 +22,12 @@
22
22
  ],
23
23
  "scripts": {
24
24
  "build": "echo 'nothing to build'",
25
+ "lint": "eslint .",
26
+ "typecheck": "tsc --noEmit",
25
27
  "test": "node --import tsx/esm --test 'test/**/*.test.ts'",
26
- "check": "npm run test",
28
+ "check": "npm run lint && npm run typecheck && npm run test",
27
29
  "pack:check": "node --import tsx/esm script/pack-check.ts",
28
- "prepublishOnly": "npm run pack:check && npm test"
30
+ "prepublishOnly": "npm run lint && npm run typecheck && npm run pack:check && npm test"
29
31
  },
30
32
  "pi": {
31
33
  "extensions": [
@@ -33,7 +35,12 @@
33
35
  ]
34
36
  },
35
37
  "devDependencies": {
36
- "tsx": "^4.19.3"
38
+ "@eslint/js": "^9.25.1",
39
+ "@types/node": "^24.7.2",
40
+ "eslint": "^9.25.1",
41
+ "tsx": "^4.19.3",
42
+ "typescript": "^5.9.3",
43
+ "typescript-eslint": "^8.31.1"
37
44
  },
38
45
  "peerDependencies": {
39
46
  "@mariozechner/pi-coding-agent": "*",