Skip to content

cli: cap the "Did you mean" hint at 5 names#9811

Open
eyupcanakman wants to merge 1 commit into
jj-vcs:mainfrom
eyupcanakman:cap-similarity-hint-8017
Open

cli: cap the "Did you mean" hint at 5 names#9811
eyupcanakman wants to merge 1 commit into
jj-vcs:mainfrom
eyupcanakman:cap-similarity-hint-8017

Conversation

@eyupcanakman

Copy link
Copy Markdown
Contributor

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:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added/updated tests to cover my changes
  • I fully understand the code that I am submitting (what it does,
    how it works, how it's organized), including any code drafted by an LLM.
  • For any prose generated by an LLM, I have proof-read and copy-edited with
    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.

@eyupcanakman
eyupcanakman requested a review from a team as a code owner July 14, 2026 13:39
Comment thread cli/src/command_error.rs Outdated
0 => Some(format!("Did you mean {quoted_names}?")),
n => Some(format!(
"Did you mean {quoted_names}, or {n} other{}?",
if n == 1 { "" } else { "s" }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point we've tried to unsuccessfully migrate away from them a bunch of times.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped it, the hint says or 1 others now. Got you three lines instead of one.

@eyupcanakman
eyupcanakman force-pushed the cap-similarity-hint-8017 branch from ed83eb7 to 09c32e5 Compare July 16, 2026 22:08
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
@eyupcanakman
eyupcanakman force-pushed the cap-similarity-hint-8017 branch from 09c32e5 to 50ced7f Compare July 17, 2026 11:22
|
= 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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I know that this functionality is a hack but it'd be nice to preserve it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants