git-watchtower 2.3.23 → 2.3.24

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/package.json +1 -1
  2. package/src/ui/renderer.js +29 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-watchtower",
3
- "version": "2.3.23",
3
+ "version": "2.3.24",
4
4
  "description": "Terminal-based Git branch monitor with activity sparklines and optional dev server with live reload",
5
5
  "main": "bin/git-watchtower.js",
6
6
  "bin": {
@@ -26,6 +26,32 @@ const { isBaseBranch } = require('../git/pr');
26
26
  const { detectInstallSource, getUpdateCommand } = require('../utils/install-source');
27
27
  const { version: PACKAGE_VERSION } = require('../../package.json');
28
28
 
29
+ // ---------------------------------------------------------------------------
30
+ // Branch-row layout helpers
31
+ // ---------------------------------------------------------------------------
32
+
33
+ /**
34
+ * Spaces to write after the (possibly truncated) branch name so the
35
+ * sparkline column lands at a consistent offset regardless of the
36
+ * branch name's actual byte count.
37
+ *
38
+ * Must measure in display columns, not UTF-16 code units. truncate()
39
+ * appends ansi.reset (4 bytes) on its long-string path; CJK / wide
40
+ * emoji span 1 code unit per 2 columns; ZWJ clusters render as 2
41
+ * columns from up to 8 units. Using raw .length would drift the
42
+ * sparkline by N columns per non-ASCII branch and by 4 for any
43
+ * truncated branch.
44
+ *
45
+ * Always returns at least 1 so consecutive writes never abut.
46
+ *
47
+ * @param {string} displayName - Already truncate()d branch name.
48
+ * @param {number} maxNameLen - Column budget the name was truncated to.
49
+ * @returns {number} Number of space characters to write.
50
+ */
51
+ function computeNamePadding(displayName, maxNameLen) {
52
+ return Math.max(1, maxNameLen - visibleLength(displayName) + 2);
53
+ }
54
+
29
55
  // ---------------------------------------------------------------------------
30
56
  // Compact number formatting
31
57
  // ---------------------------------------------------------------------------
@@ -239,7 +265,7 @@ function renderBranchList(state, write) {
239
265
  const fixedWidth = 27 + DIFF_TAG_FIXED_LEN;
240
266
  const maxNameLen = contentWidth - fixedWidth;
241
267
  const displayName = truncate(branch.name, maxNameLen);
242
- const namePadding = Math.max(1, maxNameLen - displayName.length + 2);
268
+ const namePadding = computeNamePadding(displayName, maxNameLen);
243
269
 
244
270
  if (isSelected) write(ansi.inverse);
245
271
  write(cursor);
@@ -1600,4 +1626,6 @@ module.exports = {
1600
1626
  renderStashConfirm,
1601
1627
  renderCleanupConfirm,
1602
1628
  renderUpdateModal,
1629
+ // Layout helpers — exported for unit testing
1630
+ computeNamePadding,
1603
1631
  };