cli: cap the "Did you mean" hint at 5 names#9811
Conversation
| 0 => Some(format!("Did you mean {quoted_names}?")), | ||
| n => Some(format!( | ||
| "Did you mean {quoted_names}, or {n} other{}?", | ||
| if n == 1 { "" } else { "s" } |
There was a problem hiding this comment.
FYI: The project usually does not care to make sure singular forms are used (e.g., jj abandon @ will say "Abandoned 1 commits"), but I'm not sure if this counts.
There was a problem hiding this comment.
At this point we've tried to unsuccessfully migrate away from them a bunch of times.
There was a problem hiding this comment.
jj log -r 'commit()' hits it and shows 5 candidates with one left over, so it turns up in normal use. Can drop the special case if you'd rather match the rest.
There was a problem hiding this comment.
Yes, showing up in normal use is expected (such as jj abandon @ as I said above), but the project tends not to special-handle that case. I think it'd be fine to remove the special handling (makes the code shorter by a line :p).
There was a problem hiding this comment.
Dropped it, the hint says or 1 others now. Got you three lines instead of one.
ed83eb7 to
09c32e5
Compare
With many similar bookmarks or tags, the hint could run to hundreds of characters on one line. Show the 5 most similar names and count the rest. Picking the names by similarity matters here. collect_similar() sorts alphabetically, so taking the first 5 can drop the closest match. With bookmarks named `backport-1` through `backport-12`, the hint for a typo of `backport-9` would have listed `backport-1`, `backport-10`, `backport-11`, `backport-12` and `backport-2`. Closes jj-vcs#8017
09c32e5 to
50ced7f
Compare
| | | ||
| = Keyword `builtin` doesn't exist | ||
| Hint: Did you mean `builtin_config_list`, `builtin_config_list_detailed`, `builtin_draft_commit_description`, `builtin_draft_commit_description_with_diff`, `builtin_evolog_compact`, `builtin_log_comfortable`, `builtin_log_compact`, `builtin_log_compact_full_description`, `builtin_log_detailed`, `builtin_log_node`, `builtin_log_node_ascii`, `builtin_log_oneline`, `builtin_log_redacted`, `builtin_op_log_comfortable`, `builtin_op_log_compact`, `builtin_op_log_node`, `builtin_op_log_node_ascii`, `builtin_op_log_oneline`, `builtin_op_log_redacted`, `builtin_workspace_list`, `builtin_workspace_list_with_root`? | ||
| Hint: Did you mean `builtin_config_list`, `builtin_log_compact`, `builtin_log_node`, `builtin_log_oneline`, `builtin_op_log_node`, or 16 others? |
There was a problem hiding this comment.
nit: I know that this functionality is a hack but it'd be nice to preserve it here.
The "Did you mean" hint listed every similar name, so with a lot of remote bookmarks it came out as a single line of several hundred characters. It now lists the 5 most similar names and counts the rest.
Checklist
If applicable:
CHANGELOG.mdREADME.md,docs/,demos/)cli/src/config-schema.json)how it works, how it's organized), including any code drafted by an LLM.
an eye towards deleting anything that is irrelevant, clarifying anything
that is confusing, and adding details that are relevant. This includes,
for example, commit descriptions, PR descriptions, and code comments.