bunmicro 0.9.21 → 0.9.22

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/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.22] - 2026-06-09
4
+ - Clicking on icons toggles prompts
5
+ - Unsaved star triggers save cmd
6
+ - URLs support save cursor
7
+
3
8
  ## [0.9.21] - 2026-06-09
4
9
  - Prompt mouse click repositions cursor (command and shell prompt)
5
10
  - Clicking > or $ label toggles between command/shell prompt, preserving input
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunmicro",
3
- "version": "0.9.21",
3
+ "version": "0.9.22",
4
4
  "description": "Bun JavaScript rewrite of the micro editor originally in Golang",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/index.js CHANGED
@@ -1884,8 +1884,14 @@ class App {
1884
1884
  let sx = 0, x0;
1885
1885
  // name
1886
1886
  x0 = sx;
1887
- sx = putText(this.screen, sx, statusRow, ` ${name}${dirty} `, isReadonlyBuffer(buf) ? redStatus : baseStatus, this.cols - sx);
1887
+ sx = putText(this.screen, sx, statusRow, ` ${name}`, isReadonlyBuffer(buf) ? redStatus : baseStatus, this.cols - sx);
1888
1888
  markZone("name", x0, sx);
1889
+ if (dirty) {
1890
+ x0 = sx;
1891
+ sx = putText(this.screen, sx, statusRow, dirty, baseStatus, this.cols - sx);
1892
+ markZone("dirty", x0, sx);
1893
+ }
1894
+ sx = putText(this.screen, sx, statusRow, " ", baseStatus, this.cols - sx);
1889
1895
  // (row,col)
1890
1896
  sx = putText(this.screen, sx, statusRow, "(", baseStatus, this.cols - sx);
1891
1897
  x0 = sx;
@@ -3478,6 +3484,12 @@ class App {
3478
3484
  this.nextTab();
3479
3485
  }
3480
3486
  break;
3487
+ case "dirty": {
3488
+ const name = buf?.name ?? "No name";
3489
+ const filename = /^[^\s"'\\]+$/.test(name) ? name : JSON.stringify(name);
3490
+ this.openCommandMode(`save ${filename}`);
3491
+ break;
3492
+ }
3481
3493
  case "row":
3482
3494
  if (isTerm) {
3483
3495
  this.pane.terminal?.write("\x12");
@@ -3540,10 +3552,10 @@ class App {
3540
3552
  await this.addTab();
3541
3553
  break;
3542
3554
  case "cmdmode":
3543
- this.openCommandMode();
3555
+ await this.togglePromptMode("Command");
3544
3556
  break;
3545
3557
  case "shellmode":
3546
- this.openShellMode();
3558
+ await this.togglePromptMode("Shell");
3547
3559
  break;
3548
3560
  }
3549
3561
  return true;
@@ -3753,6 +3765,18 @@ class App {
3753
3765
  this.prompt = new Prompt(label, callback, { yn: true, onCancel });
3754
3766
  }
3755
3767
 
3768
+ async togglePromptMode(type) {
3769
+ if (this.prompt?.type === type) {
3770
+ const prompt = this.prompt;
3771
+ this.prompt = null;
3772
+ await prompt.onCancel?.();
3773
+ return;
3774
+ }
3775
+
3776
+ if (type === "Command") this.openCommandMode();
3777
+ else this.openShellMode();
3778
+ }
3779
+
3756
3780
  async checkExternalReload() {
3757
3781
  if (this.prompt || this.pane?.type !== "editor") return false;
3758
3782
  const buf = this.buffer;
@@ -5649,17 +5673,18 @@ function commandHasStartupJump(command = {}) {
5649
5673
  }
5650
5674
 
5651
5675
  async function loadBufferForPath(pathOrUrl, context, command = {}) {
5676
+ let buffer;
5652
5677
  if (isHttpUrl(pathOrUrl)) {
5653
5678
  let encoding = context.config?.globalSettings?.encoding ?? DEFAULT_SETTINGS.encoding;
5654
5679
  const decoded = await fetchTextWithEncoding(pathOrUrl, encoding);
5655
5680
  const text = decoded.text;
5656
5681
  encoding = decoded.encoding;
5657
5682
  const urlPath = pathOrUrl.replace(/[?#].*$/, "");
5658
- const buffer = new BufferModel({ path: pathOrUrl, text, command, encoding });
5683
+ buffer = new BufferModel({ path: pathOrUrl, text, command, encoding });
5659
5684
  attachSyntax(buffer, context, urlPath, text);
5660
- return buffer;
5685
+ } else {
5686
+ buffer = await BufferModel.fromFile(pathOrUrl, command, context);
5661
5687
  }
5662
- const buffer = await BufferModel.fromFile(pathOrUrl, command, context);
5663
5688
  if (DEFAULT_SETTINGS.savecursor && !commandHasStartupJump(command) && context?.cursorStates?.[pathOrUrl]) {
5664
5689
  const saved = context.cursorStates[pathOrUrl];
5665
5690
  const y = clamp(saved.y ?? 0, 0, buffer.lines.length - 1);