From 22a4e3d19ce7ae89efbe13bd139aa99dedb55b90 Mon Sep 17 00:00:00 2001 From: Jack Platten Date: Tue, 20 Oct 2026 19:08:09 -0700 Subject: [PATCH] fix(jj): ignore length settings that aren't whole numbers (#114) A non-numeric (or empty) tide_jj_bookmark_length or tide_jj_description_length made `test` print "Argument is not a number" from the background render on every prompt, and turned truncation off. Only accept whole numbers and fall back to the default otherwise. Claude-Session: https://claude.ai/code/session_01PVbQM4XyH5HLzapJWmWTU1 Co-authored-by: Claude --- functions/_tide_internal_vcs_jj.fish | 6 ++++-- tests/_tide_item_vcs.test.fish | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/functions/_tide_internal_vcs_jj.fish b/functions/_tide_internal_vcs_jj.fish index 013435a..197e6de 100644 --- a/functions/_tide_internal_vcs_jj.fish +++ b/functions/_tide_internal_vcs_jj.fish @@ -107,7 +107,9 @@ if(self.contained_in("::trunk() & ~::@"), # Bookmark names are often long ticket slugs, so cap each one's length # (configurable via tide_jj_bookmark_length; 0 disables truncation). set -l bm_length 24 - set -q tide_jj_bookmark_length; and set bm_length $tide_jj_bookmark_length + # Only a whole number counts, so a typo falls back to the default + # instead of erroring from the background render. + string match -qr '^\d+$' -- "$tide_jj_bookmark_length" && set bm_length $tide_jj_bookmark_length set -l info "" set -l has_conflict 0 @@ -194,7 +196,7 @@ if(self.contained_in("::trunk() & ~::@"), set -l show_desc true set -q tide_jj_show_description; and set show_desc $tide_jj_show_description set -l desc_length 24 - set -q tide_jj_description_length; and set desc_length $tide_jj_description_length + string match -qr '^\d+$' -- "$tide_jj_description_length" && set desc_length $tide_jj_description_length set -l desc_label "" if test -n "$parts[8]"; and test "$show_desc" = true set -l desc $parts[8] diff --git a/tests/_tide_item_vcs.test.fish b/tests/_tide_item_vcs.test.fish index 50475ce..91c80be 100644 --- a/tests/_tide_item_vcs.test.fish +++ b/tests/_tide_item_vcs.test.fish @@ -181,8 +181,22 @@ set -g tide_jj_bookmark_length 10 _vcs_item # CHECK: (@ xyz999 this-is-a-… def999 * desc feature/ab…↑1 ↑2) set -g tide_jj_bookmark_length 0 _vcs_item # CHECK: (@ xyz999 this-is-a-very-long-at-bookmark-name def999 * desc feature/abc-123-some-very-long-ticket-description↑1 ↑2) +# A value that isn't a whole number falls back to the default instead of +# printing an error from the background render (littlecheck fails on stderr) +set -g tide_jj_bookmark_length abc +_vcs_item # CHECK: (@ xyz999 this-is-a-very-long-at-b… def999 * desc feature/abc-123-some-ver…↑1 ↑2) +set -g tide_jj_bookmark_length +_vcs_item # CHECK: (@ xyz999 this-is-a-very-long-at-b… def999 * desc feature/abc-123-some-ver…↑1 ↑2) set -e tide_jj_bookmark_length +set -g tide_jj_description_length abc +set -g tide_jj_show_description true +mkdir -p $dir/jj-longdesc-repo/.jj +printf '#!/bin/sh\ncmd="$*"\ncase "$cmd" in\n *"workspace list"*) printf "default\\n" ;;\n *"log"*) printf "xyz999\\t.\\t.\\tdefault\\tdef999\\t*\\tfalse\\ta description that is far too long to show\\n" ;;\n *) exit 0 ;;\nesac\n' >$dir/bin/jj +cd $dir/jj-longdesc-repo +_vcs_item # CHECK: (@ xyz999 def999 * a description that is fa… ↑1) +set -e tide_jj_description_length + set -e tide_jj_show_description set -q saved_show_desc[1] && set -U tide_jj_show_description $saved_show_desc -- knotmirror 0.0.1