Skip to content

Fix historical compare target resets and blame sync - #585

Open
Pyrdon wants to merge 1 commit into
jisaacks:masterfrom
Pyrdon:feature-fix-minidiff-save-override
Open

Pyrdon wants to merge 1 commit into
jisaacks:masterfrom
Pyrdon:feature-fix-minidiff-save-override

Conversation

@Pyrdon

@Pyrdon Pyrdon commented Sep 8, 2026

Copy link
Copy Markdown

Description

This PR fixes a set of synchronization bugs between GitGutter's historical compare targets and Sublime Text's native mini_diff engine, ensuring the diff and inline blame stay locked to the user's chosen commit.

Root Causes & Fixes

  • Path casing cache misses: On Windows/case-insensitive OSs, atomic saves can shift path casing. The strict string inequality in work_tree() triggered false renames, resetting the target to HEAD. Fix: Wrapped the is_renamed check in os.path.normcase().
  • The POST_SAVE reset: Sublime Text automatically resets the native set_reference_document to the git index upon saving a file. Because GitGutter's _git_compared_commit cache remained intact, it silently aborted re-injecting the historical commit. Fix: Added events.POST_SAVE to the invalidation trigger in commands.py and forced _git_compared_commit = None in handler.py to guarantee a re-fetch and re-injection on save.
  • Blame Ignoring Target: The git_blame() shell execution completely omitted the compare target, causing inline annotations to always evaluate against HEAD. Fix: Retrieved the target via get_compare_against() and injected it before the -- separator in the subprocess arguments.

Testing

Verified locally on ST4. Modifying a file, saving it, and triggering popups/inline diffs now correctly maintains the selected historical commit target without visual overlap or state drops.

This resolves three distinct state-sync bugs:
* Ensured file paths are compared by normalizing file name casing on
  case-insensitive filesystems. Otherwise, saving a file could trigger a false
  rename detection and silently reset the active diff target back to HEAD.
* Ensured a save to a file forces GitGutter to re-inject the historical document
  reference and override Sublime Text's default diff on save. Otherwise, the
  native mini-diff will fall out of sync with the GitGutter diff.
* Ensured the inline phantoms compare to the selected historical commit.
  Otherwise, the blame annotations default to HEAD and display incorrect
  historical data.
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.

1 participant