@kaynooo/cli-pick 0.9.2 → 0.9.3

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/pick.js +13 -3
  2. package/package.json +2 -2
package/dist/pick.js CHANGED
@@ -326,6 +326,9 @@ function upTo(text, separator) {
326
326
  return end === -1 ? text : text.slice(0, end);
327
327
  }
328
328
  var ESCAPE = String.fromCharCode(27);
329
+ function textWidth(text) {
330
+ return Bun.stringWidth(text);
331
+ }
329
332
  function jsonText(value, replacer, { stream = process7.stdout, env = process7.env } = {}) {
330
333
  return JSON.stringify(value, replacer, outputMode(stream, env) === "agent" ? undefined : 2);
331
334
  }
@@ -1111,6 +1114,14 @@ import { openSync } from "fs";
1111
1114
  import process15 from "process";
1112
1115
  import tty from "tty";
1113
1116
 
1117
+ // ../kit/src/redraw.ts
1118
+ var SYNC_START = "\x1B[?2026h";
1119
+ var SYNC_END = "\x1B[?2026l";
1120
+ function overwrite(lines, columns) {
1121
+ return lines.map((line) => textWidth(line) < columns ? `${line}\x1B[K` : `\x1B[2K${line}`).join(`
1122
+ `);
1123
+ }
1124
+
1114
1125
  // ../kit/src/picker/preview.ts
1115
1126
  import process14 from "process";
1116
1127
 
@@ -1383,14 +1394,13 @@ async function select(rows, settings, terminal = openTerminal()) {
1383
1394
  if (restored)
1384
1395
  return;
1385
1396
  const layout = layoutFor({ columns: terminal.columns, rows: terminal.rows }, settings.height, settings.preview !== undefined, settings.previewPosition);
1386
- let frame = HIDE_CURSOR;
1397
+ let frame = SYNC_START + HIDE_CURSOR;
1387
1398
  if (reserved !== layout.height || clear) {
1388
1399
  frame += CLEAR_BELOW + `
1389
1400
  `.repeat(layout.height - 1) + up(layout.height - 1);
1390
1401
  reserved = layout.height;
1391
1402
  }
1392
- frame += `\r${render(state, layout, theme, preview).map((line) => `\x1B[2K${line}`).join(`
1393
- `)}${up(layout.height - 1)}\r\x1B[${caretColumn(state, layout)}G${CARET}\r`;
1403
+ frame += `\r${overwrite(render(state, layout, theme, preview), terminal.columns)}${up(layout.height - 1)}\r\x1B[${caretColumn(state, layout)}G${CARET}\r${SYNC_END}`;
1394
1404
  terminal.write(frame);
1395
1405
  }
1396
1406
  function pageSize() {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-pick",
3
3
  "type": "module",
4
- "version": "0.9.2",
4
+ "version": "0.9.3",
5
5
  "description": "pick: a themed fuzzy selector, lines on stdin, the chosen one on stdout.",
6
6
  "author": "Kaynooo <contact@kaynooo.fr>",
7
7
  "license": "MIT",
@@ -35,6 +35,6 @@
35
35
  "pick": "$npm_execpath src/pick.ts"
36
36
  },
37
37
  "devDependencies": {
38
- "@kaynooo/cli-kit": "0.38.3"
38
+ "@kaynooo/cli-kit": "0.38.4"
39
39
  }
40
40
  }