live_diff: add live_diff.enabled_on_startup config option#2002
Open
sinelaw wants to merge 1 commit into
Open
Conversation
Closes #1950. Live Diff is opt-in: every session starts with the global toggle off and the user has to invoke "Live Diff: Toggle (Global)" from the command palette before decorations appear. Users who rely on Live Diff as part of their normal workflow asked for a way to skip the manual toggle. Adds a new top-level `live_diff` config section with a single `enabled_on_startup` field (default false, preserving current behavior). When true, the live_diff plugin force-enables the global toggle the first time it sees a buffer event, regardless of any persisted state. The user can still toggle off mid-session; the next startup re-enables it, which is the requested semantics. The check is deferred via `applyStartupConfigOnce()` rather than run at plugin load: `editor.getConfig()` reads from a snapshot the editor refreshes between ticks, and the plugin can execute before that snapshot is populated. E2E test creates a `Config` with `enabled_on_startup = true`, opens a modified file, and waits for the `+` gutter glyph — no command-palette invocation. The default-off path is exercised by every other `live_diff` test in the file, all of which call `enable_live_diff_globally` to flip the toggle.
Owner
Author
|
Plugins need their own dedicated config value registration mechanism so that we don't hard code them into rust or touch the config.rs when updating a plugin's config abilities |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1950.
Summary
Live Diff is opt-in: every session starts with the global toggle off, so users who rely on it have to invoke
Live Diff: Toggle (Global)from the command palette before decorations appear. This adds a newlive_diff.enabled_on_startupconfig field (defaultfalse, preserving current behavior). Whentrue, the plugin force-enables the global toggle on startup — equivalent to the manual toggle, but automatic.The user can still toggle Live Diff off mid-session via the command palette; the next startup re-enables it, which matches the requested "always on" semantics.
Implementation
LiveDiffConfigstruct inconfig.rswith a singleenabled_on_startup: boolfield, alongside the existingterminal,clipboard, etc. sections. Default impl matches theWarningsConfig/TerminalConfigpattern. Schema regenerated via./scripts/gen_schema.sh.PartialLiveDiffConfiginpartial_config.rs(Merge + From + resolve) so layered config loading handles the new section.live_diff.tsreadsconfig.live_diff.enabled_on_startupviaeditor.getConfig()and force-enables the global state. The check is gated by astartupConfigAppliedboolean and fires lazily on the first buffer event (after_file_open/buffer_activated/ plugin init with an active buffer) rather than at plugin load —getConfig()reads from a snapshot that the editor refreshes between ticks, so it can return{}if the plugin runs first.Test plan
test_live_diff_enabled_on_startup_config_renders_without_manual_togglebuilds aConfigwithenabled_on_startup = true, opens a modified file, and asserts the+gutter glyph appears with no command-palette invocation. Fails without the change (the existing test had to callenable_live_diff_globallyfor the same gutter to appear).live_diffe2e tests pass (cargo test --test e2e_tests -p fresh-editor live_diff).cargo test --test e2e_tests -p fresh-editor plugins::).cargo test -p fresh-editor --lib config::), including the roundtrip-to-partial test.live_diff.enabled_on_startup: true, opening a modified file shows the+gutter glyph with no toggling.live_diff.enabled_on_startup: false(default), the gutter stays empty until the user runs the toggle command.Generated by Claude Code