@blankdotpage/cake 0.1.72 → 0.1.73

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;AAknC5B,+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;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"}
@@ -663,6 +663,34 @@ function handleToggleList(state, isBullet) {
663
663
  newSource.slice(block.endOffset);
664
664
  }
665
665
  }
666
+ if (selection.start === selection.end && startLine === endLine) {
667
+ const originalCursorSource = map.cursorToSource(selection.start, selection.affinity ?? "forward");
668
+ const originalLineInfo = getLineInfo(source, originalCursorSource);
669
+ const originalLine = lines[startLine] ?? "";
670
+ const nextLines = getSourceLines(newSource);
671
+ const nextLine = nextLines[startLine] ?? "";
672
+ const originalPrefixLength = getListPrefixLength(originalLine) ?? 0;
673
+ const nextPrefixLength = getListPrefixLength(nextLine) ?? 0;
674
+ const originalContentLength = Math.max(0, originalLine.length - originalPrefixLength);
675
+ const nextContentLength = Math.max(0, nextLine.length - nextPrefixLength);
676
+ const cursorOffsetInContent = Math.max(0, Math.min(originalContentLength, originalLineInfo.offsetInLine - originalPrefixLength));
677
+ const nextOffsetInContent = Math.min(nextContentLength, cursorOffsetInContent);
678
+ let nextCursorSourceOffset = 0;
679
+ for (let i = 0; i < startLine; i += 1) {
680
+ nextCursorSourceOffset += (nextLines[i] ?? "").length + 1;
681
+ }
682
+ nextCursorSourceOffset += nextPrefixLength + nextOffsetInContent;
683
+ const next = runtime.createState(newSource);
684
+ const nextCursor = next.map.sourceToCursor(nextCursorSourceOffset, "forward");
685
+ return {
686
+ source: newSource,
687
+ selection: {
688
+ start: nextCursor.cursorOffset,
689
+ end: nextCursor.cursorOffset,
690
+ affinity: nextCursor.affinity,
691
+ },
692
+ };
693
+ }
666
694
  // Calculate new selection to preserve the selected range
667
695
  const newSourceLines = getSourceLines(newSource);
668
696
  let newStartSourceOffset = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blankdotpage/cake",
3
- "version": "0.1.72",
3
+ "version": "0.1.73",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",