@nbtca/prompt 1.5.6 → 1.5.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.
@@ -1,4 +1,4 @@
1
- import { type, space, glyph, brandMark } from '../core/theme.js';
1
+ import { type, space, glyph, brandMark, MAX_FRAME_COLS } from '../core/theme.js';
2
2
  import { pickIcon } from '../core/icons.js';
3
3
  import { t } from '../i18n/index.js';
4
4
  import { clipAnsiToVisualWidth, visualWidth } from '../core/text.js';
@@ -19,7 +19,8 @@ export function resolveChromeLayout(rows) {
19
19
  return { headerLines: 0, footerLines: 0 };
20
20
  }
21
21
  function renderRule(cols) {
22
- const width = Number.isFinite(cols) ? Math.max(1, Math.floor(cols)) : 80;
22
+ const terminal = Number.isFinite(cols) ? Math.max(1, Math.floor(cols)) : 80;
23
+ const width = Math.min(terminal, MAX_FRAME_COLS);
23
24
  const indent = visualWidth(space.indent) < width ? space.indent : '';
24
25
  const ruleWidth = Math.max(1, width - visualWidth(indent) * 2);
25
26
  return indent + type.hint(glyph.rule().repeat(ruleWidth));
@@ -146,8 +147,9 @@ export function renderFooter(_active, cols, tabCount, overrideHint, lineCount =
146
147
  function withPosition(hint, hintText, indent, position, cols) {
147
148
  if (position === undefined)
148
149
  return hint;
149
- const margin = visualWidth(space.indent) < cols ? space.indent : '';
150
- const gap = cols - visualWidth(indent + hintText) - visualWidth(position) - visualWidth(margin);
150
+ const frame = Math.min(cols, MAX_FRAME_COLS);
151
+ const margin = visualWidth(space.indent) < frame ? space.indent : '';
152
+ const gap = frame - visualWidth(indent + hintText) - visualWidth(position) - visualWidth(margin);
151
153
  if (gap < 2)
152
154
  return hint;
153
155
  return hint + ' '.repeat(gap) + type.hint(position) + margin;
@@ -42,6 +42,8 @@ export const glyph = {
42
42
  barFilled: () => pickIcon('█', '#'),
43
43
  barEmpty: () => pickIcon('░', '-'),
44
44
  };
45
+ /** Beyond this the app stops stretching; a terminal wider than this keeps the slack. */
46
+ export const MAX_FRAME_COLS = 100;
45
47
  export const space = {
46
48
  indent: ' ',
47
49
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nbtca/prompt",
3
- "version": "1.5.6",
3
+ "version": "1.5.7",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "exports": {