phewsh 0.15.6 → 0.15.7

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.
@@ -774,7 +774,10 @@ async function main() {
774
774
  const lineCount = text.split('\n').length;
775
775
  if (lineCount > 1 || text.length > 200) {
776
776
  pasteCounter++;
777
- const tag = `[paste #${pasteCounter}: ${text.length.toLocaleString('en-US')} chars, ${lineCount} lines]`;
777
+ const chars = text.length.toLocaleString('en-US');
778
+ const tag = lineCount > 1
779
+ ? `[paste #${pasteCounter}: ${chars} chars, ${lineCount} lines]`
780
+ : `[paste #${pasteCounter}: ${chars} chars]`;
778
781
  pendingPastes.set(tag, text);
779
782
  lastPaste = text;
780
783
  rl.write(tag);
@@ -825,11 +828,18 @@ async function main() {
825
828
  return;
826
829
  }
827
830
  // Re-render so token coloring tracks edits — including the keystroke
828
- // where the token stops matching and must un-color.
829
- const cur = rl.line || '';
830
- const special = cur[0] === '/' || cur[0] === '@';
831
- if (special || wasSpecialInput) rl._refreshLine();
832
- wasSpecialInput = special;
831
+ // where the token stops matching and must un-color. Deferred one tick:
832
+ // this is a prependListener, so readline hasn't appended the just-typed
833
+ // char yet; without the defer, rl.line is stale by one and /model only
834
+ // ever evaluates as /mode.
835
+ setImmediate(() => {
836
+ try {
837
+ const cur = rl.line || '';
838
+ const special = cur[0] === '/' || cur[0] === '@';
839
+ if (special || wasSpecialInput) rl._refreshLine();
840
+ wasSpecialInput = special;
841
+ } catch { /* never break input */ }
842
+ });
833
843
  } catch { /* never break input */ }
834
844
  };
835
845
  process.stdin.prependListener('keypress', phewshKeypress);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phewsh",
3
- "version": "0.15.6",
3
+ "version": "0.15.7",
4
4
  "description": "Turn intent into action. Structure your thinking, execute your next step.",
5
5
  "bin": {
6
6
  "phewsh": "bin/phewsh.js"