Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

diffedit: start the builtin ui with all boxes checked #5393

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

v-gb
Copy link
Contributor

@v-gb v-gb commented Jan 18, 2025

(fixes #5390)

Currently, there is a blocker: when quitting the ui with 'q' after making no changes, you get prompted with 'you have modified N files, are you sure?', which seems like a bug in the scm_record library.

Separately, I tested this manually but I'm unsure whether and how I should add automated tests. The problem is that this change only affects the builtin UI, which I don't know how to test automatically. If I make external tools support this new InitialSelection parameter, I could test that diffedit receives InitialSelection::All, but not the bulk of the change.

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 tests to cover my changes

(fixes jj-vcs#5390)

Currently, there is a blocker: when quitting the ui with 'q' after making no
changes, you get prompted with 'you have modified N files, are you sure?', which
seems like a bug in the scm_record library.
Copy link
Contributor

@arxanas arxanas left a comment

Choose a reason for hiding this comment

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

Thanks for implementing this (and filing the bug upstream on scm-record)!

Re testing:

  • I guess it would be good to add a unit test to mod tests to ensure that InitialSelection::All is respected for all kinds of sections we know how to render, and ensure we have some coverage for that code path.
  • I don't see a good way of adding a test that confirms that the InitialSelection is threaded all the way down to the appropriate diff editor usage sites.
    • IIRC we don't have any TUI tests at present.
    • You could also reasonably argue that it's a specification issue rather than an implementation issue, so such a test may be low-value compared to implementation effort.
    • Having the enum should reduce likelihood of type confusion with other booleans.

Comment on lines +2958 to +2959
format_instructions,
InitialSelection::None,
Copy link
Contributor

Choose a reason for hiding this comment

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

comment (non-blocking): We could consider if we want to bundle the "configuration" kind of arguments here into a single struct for organizational reasons, but I don't feel strongly.

@v-gb
Copy link
Contributor Author

v-gb commented Jan 18, 2025

Thanks! I'll see about adding some unit tests.

@@ -255,14 +256,17 @@ impl DiffEditor {
right_tree: &MergedTree,
matcher: &dyn Matcher,
format_instructions: impl FnOnce() -> String,
initial_selection: InitialSelection,
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe better to always open builtin editor with everything checked?

It's weird that initial_selection applies only to the builtin editor. External editor opens with the right content (i.e. everything selected?)

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have a strong opinion myself, but the per-command difference was discussed here: #5390 (comment)

It seems to make sense to me that we would want e.g. split to start with nothing but diffedit to start with everything. Maybe it's more of a limitation with external diff editors? Is there a way to indicate to an external diff editor "here is a set of changes, but don't apply any of them by default"?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think there's a way of telling external 2-way diff editors that. But we can tell external 3-way diff editors that by setting the middle state to be either the same as the left (for split) or the same as the right (for diffedit).

By the way, another aspect is what the effect of starting the diff editor and immediately quitting should do. One could argue that it should have the same effect as not even starting it. split and diffedit are always interactive (unless you pass paths to split), but squash and restore can be non-interactive. Is it important to us that jj squash has the same effect as running jj squash -i and immediately closing the diff editor? I'm fine with that inconsistency.

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.

FR: keep the whole diff in diffedit's initial state?
4 participants