ucode-agent 1.62.1 → 1.62.2

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/src/ui/theme.js CHANGED
@@ -230,9 +230,6 @@ export function visLen(s) {
230
230
  const cp = text.codePointAt(i);
231
231
  const ch = String.fromCodePoint(cp);
232
232
  i += ch.length;
233
- // A variation selector turns the character before it into an emoji, and
234
- // an emoji is two cells wide however narrow its text form was.
235
- if (text.codePointAt(i) === 0xfe0f) { cells += 2; i += 1; continue; }
236
233
  cells += charWidth(cp);
237
234
  }
238
235
  return cells;
@@ -252,18 +249,27 @@ export function sliceVis(s, width) {
252
249
  // in the rest.
253
250
  const cp = s.codePointAt(i);
254
251
  const ch = String.fromCodePoint(cp);
255
- const selector = s.codePointAt(i + ch.length) === 0xfe0f;
256
- const w = selector ? 2 : charWidth(cp);
252
+ const w = charWidth(cp);
257
253
  if (seen + w > width) break;
258
- out += selector ? ch + String.fromCodePoint(0xfe0f) : ch;
259
- i += (selector ? ch.length + 1 : ch.length) - 1;
254
+ out += ch;
255
+ i += ch.length - 1;
260
256
  seen += w;
261
257
  }
262
258
  return out;
263
259
  }
264
260
 
265
- /** Pad or hard-cut a possibly-coloured string to an exact visible width. */
266
- export function padVis(s, width) {
261
+ /**
262
+ * Pad or hard-cut a possibly-coloured string to an exact visible width.
263
+ *
264
+ * The emoji variation selector (U+FE0F) is dropped on the way out. Terminals
265
+ * disagree on what it does to a character like ❤ — Windows Terminal draws two
266
+ * cells, macOS Terminal draws one — so no count of it is right on both, and a
267
+ * row holding one had its right border a column off on the Mac. Without it the
268
+ * character is drawn in its plain form, one cell, everywhere. Every painted row
269
+ * passes through here, so this is the one place it needs doing.
270
+ */
271
+ export function padVis(raw, width) {
272
+ const s = String(raw).replace(/️/g, '');
267
273
  const len = visLen(s);
268
274
  if (len === width) return s;
269
275
  if (len < width) return s + ' '.repeat(width - len);