pi-vim 0.11.0 → 0.11.1

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/index.ts +13 -2
  2. package/package.json +1 -1
  3. package/types.ts +1 -1
package/index.ts CHANGED
@@ -1215,6 +1215,7 @@ export class ModalEditor extends CustomEditor {
1215
1215
  if ("insert" === this.mode) {
1216
1216
  this.clearUnderlyingPasteStateIfActive();
1217
1217
  this.setMode("normal");
1218
+ if (this.getCursor().col > 0) this.moveCursorBy(-1);
1218
1219
  } else {
1219
1220
  super.handleInput("\x1b"); // pass escape to abort agent
1220
1221
  }
@@ -1996,6 +1997,12 @@ export class ModalEditor extends CustomEditor {
1996
1997
  this.setMode();
1997
1998
  this.moveCursorToFirstNonWhitespace();
1998
1999
  break;
2000
+ case "$": {
2001
+ const { line } = this.getCurrentLineAndCol();
2002
+ const graphemes = getLineGraphemes(line);
2003
+ this.moveCursorToCol(graphemes[graphemes.length - 1]?.start ?? 0);
2004
+ break;
2005
+ }
1999
2006
  case "o":
2000
2007
  this.openLineBelow();
2001
2008
  this.setMode();
@@ -2023,7 +2030,7 @@ export class ModalEditor extends CustomEditor {
2023
2030
  this.setMode();
2024
2031
  break;
2025
2032
  case "x":
2026
- this.cutCharUnderCursor();
2033
+ this.cutCharUnderCursor(true);
2027
2034
  break;
2028
2035
  case "j":
2029
2036
  this.moveCursorVertically(1);
@@ -2655,7 +2662,7 @@ export class ModalEditor extends CustomEditor {
2655
2662
  return col >= line.length;
2656
2663
  }
2657
2664
 
2658
- private cutCharUnderCursor(): void {
2665
+ private cutCharUnderCursor(normal: boolean = false): void {
2659
2666
  const count = Math.max(1, Math.min(MAX_COUNT, this.takeTotalCount(1)));
2660
2667
  const cursor = this.getCursor();
2661
2668
  const line = this.getLines()[cursor.line] ?? "";
@@ -2670,6 +2677,10 @@ export class ModalEditor extends CustomEditor {
2670
2677
  text.slice(lineStartAbs + range.end),
2671
2678
  lineStartAbs + range.start,
2672
2679
  );
2680
+ if (normal) {
2681
+ const { line, col } = this.getCurrentLineAndCol();
2682
+ if (line && col >= line.length) this.moveCursorBy(-1);
2683
+ }
2673
2684
  }
2674
2685
 
2675
2686
  private cutToEndOfLine(): void {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-vim",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "Vim-style modal editing for Pi's TUI editor",
5
5
  "type": "module",
6
6
  "keywords": [
package/types.ts CHANGED
@@ -19,7 +19,7 @@ export const NORMAL_KEYS: Record<string, string | null> = {
19
19
  k: "\x1b[A", // up
20
20
  l: "\x1b[C", // right
21
21
  "0": "\x01", // line start
22
- $: "\x05", // line end
22
+ $: null, // line end
23
23
  x: null, // delete char (custom clipboard handling)
24
24
  D: null, // delete to end of line (custom clipboard handling)
25
25
  C: null, // change to end of line (delete to end + insert mode)