@nomad-e/bluma-cli 0.0.42 → 0.0.43

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 (2) hide show
  1. package/dist/main.js +29 -9
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -142,9 +142,15 @@ function inputReducer(state, action, viewWidth) {
142
142
  }
143
143
  case "SET": {
144
144
  const t = action.payload.text.replace(/(||)/gm, "");
145
- const moveToEnd = action.payload.moveCursorToEnd ?? true;
145
+ let newCursorPosition;
146
+ if (typeof action.payload.cursorPosition === "number") {
147
+ newCursorPosition = Math.min(action.payload.cursorPosition, t.length);
148
+ } else if (action.payload.moveCursorToEnd ?? true) {
149
+ newCursorPosition = t.length;
150
+ } else {
151
+ newCursorPosition = Math.min(state.cursorPosition, t.length);
152
+ }
146
153
  const newText = t;
147
- const newCursorPosition = moveToEnd ? newText.length : Math.min(state.cursorPosition, newText.length);
148
154
  const newViewStart = adjustView(newCursorPosition, 0);
149
155
  return { text: newText, cursorPosition: newCursorPosition, viewStart: newViewStart };
150
156
  }
@@ -375,12 +381,16 @@ function useAtCompletion({
375
381
  let chosen = suggestions[selected].label;
376
382
  const isDir = suggestions[selected].isDir;
377
383
  chosen = chosen.replace(/\\/g, "/").replace(/\|/g, "");
378
- let insertVal = chosen;
379
- if (insertVal.includes("/")) {
380
- insertVal = insertVal.replace(/\/+$/g, "");
381
- const parts = insertVal.split("/");
382
- insertVal = parts[parts.length - 1];
384
+ let insertVal = chosen.replace(/\/+$/g, "");
385
+ const currentPattern = res.pattern || "";
386
+ if (currentPattern.length > 0) {
387
+ const normalizedPattern = currentPattern.replace(/\/+$/g, "");
388
+ if (insertVal.startsWith(normalizedPattern)) {
389
+ insertVal = insertVal.slice(normalizedPattern.length);
390
+ insertVal = insertVal.replace(/^\/+/, "");
391
+ }
383
392
  }
393
+ insertVal = insertVal.split("\\").join("/");
384
394
  if (isDir && !insertVal.endsWith("/")) insertVal = insertVal + "/";
385
395
  const pattern = res.pattern || "";
386
396
  const lastSlash = pattern.lastIndexOf("/");
@@ -389,13 +399,16 @@ function useAtCompletion({
389
399
  const before = text.slice(0, segmentStart);
390
400
  const after = text.slice(cursorPosition);
391
401
  const newText = before + insertVal + after;
392
- setText(newText + (isDir ? "" : " "), true);
402
+ const finalText = newText + " ";
403
+ setText(finalText, finalText.length);
404
+ globalThis.__BLUMA_FORCE_CURSOR_END__ = true;
405
+ update(finalText, finalText.length);
393
406
  if (isDir) {
394
407
  setOpen(false);
395
408
  setSuggestions([]);
396
409
  setTimeout(() => {
397
410
  setOpen(true);
398
- update(newText, newText.length);
411
+ update(finalText, finalText.length);
399
412
  }, 0);
400
413
  } else {
401
414
  setOpen(false);
@@ -496,6 +509,12 @@ var InputPrompt = ({ onSubmit, isReadOnly, onInterrupt, disableWhileProcessing =
496
509
  setSlashOpen(false);
497
510
  }
498
511
  }, { isActive: slashOpen });
512
+ useEffect2(() => {
513
+ if (globalThis.__BLUMA_FORCE_CURSOR_END__) {
514
+ setText(text, text.length);
515
+ delete globalThis.__BLUMA_FORCE_CURSOR_END__;
516
+ }
517
+ }, [text, setText]);
499
518
  const cwd = process.cwd();
500
519
  const pathAutocomplete = useAtCompletion({ cwd, text, cursorPosition, setText });
501
520
  useInput2((input, key) => {
@@ -514,6 +533,7 @@ var InputPrompt = ({ onSubmit, isReadOnly, onInterrupt, disableWhileProcessing =
514
533
  if (m) {
515
534
  globalThis.__BLUMA_SUPPRESS_SUBMIT__ = true;
516
535
  pathAutocomplete.insertAtSelection();
536
+ return;
517
537
  }
518
538
  }
519
539
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nomad-e/bluma-cli",
3
- "version": "0.0.42",
3
+ "version": "0.0.43",
4
4
  "description": "BluMa independent agent for automation and advanced software engineering.",
5
5
  "author": "Alex Fonseca",
6
6
  "license": "Apache-2.0",