@blankdotpage/cake 0.1.73 → 0.1.74

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.
@@ -1 +1 @@
1
- {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../src/cake/extensions/list/list.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAGnB,MAAM,oBAAoB,CAAC;AAoqC5B,+CAA+C;AAC/C,MAAM,MAAM,uBAAuB,GAAG;IAAE,IAAI,EAAE,oBAAoB,CAAA;CAAE,CAAC;AAErE,iDAAiD;AACjD,MAAM,MAAM,yBAAyB,GAAG;IAAE,IAAI,EAAE,sBAAsB,CAAA;CAAE,CAAC;AAEzE,kCAAkC;AAClC,MAAM,MAAM,WAAW,GAAG,uBAAuB,GAAG,yBAAyB,CAAC;AAE9E,eAAO,MAAM,sBAAsB,EAAE,aA8HpC,CAAC"}
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../src/cake/extensions/list/list.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAGnB,MAAM,oBAAoB,CAAC;AA0qC5B,+CAA+C;AAC/C,MAAM,MAAM,uBAAuB,GAAG;IAAE,IAAI,EAAE,oBAAoB,CAAA;CAAE,CAAC;AAErE,iDAAiD;AACjD,MAAM,MAAM,yBAAyB,GAAG;IAAE,IAAI,EAAE,sBAAsB,CAAA;CAAE,CAAC;AAEzE,kCAAkC;AAClC,MAAM,MAAM,WAAW,GAAG,uBAAuB,GAAG,yBAAyB,CAAC;AAE9E,eAAO,MAAM,sBAAsB,EAAE,aA8HpC,CAAC"}
@@ -585,19 +585,23 @@ function handleToggleList(state, isBullet) {
585
585
  if (selection.start === selection.end && startLine === endLine && lines[startLine] === "") {
586
586
  const marker = isBullet ? "- " : "1. ";
587
587
  newLines[startLine] = marker;
588
- // Calculate new selection position (after the marker)
589
- let newCursorPos = 0;
588
+ // Calculate new source position after the inserted marker.
589
+ let newCursorSourcePos = 0;
590
590
  for (let i = 0; i < startLine; i++) {
591
- newCursorPos += lines[i].length + 1; // +1 for newline
591
+ newCursorSourcePos += lines[i].length + 1; // +1 for newline
592
592
  }
593
- newCursorPos += marker.length;
593
+ newCursorSourcePos += marker.length;
594
594
  const newSource = newLines.join("\n");
595
+ const next = runtime.createState(newSource);
596
+ // Bias backward so the caret stays on the newly created empty list line
597
+ // instead of normalizing to the following line at the shared boundary.
598
+ const nextCursor = next.map.sourceToCursor(newCursorSourcePos, "backward");
595
599
  return {
596
600
  source: newSource,
597
601
  selection: {
598
- start: newCursorPos,
599
- end: newCursorPos,
600
- affinity: "forward",
602
+ start: nextCursor.cursorOffset,
603
+ end: nextCursor.cursorOffset,
604
+ affinity: nextCursor.affinity,
601
605
  },
602
606
  };
603
607
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blankdotpage/cake",
3
- "version": "0.1.73",
3
+ "version": "0.1.74",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",