fix: commit scope突入時にgitsignsのper-bufferベースを再適用する - #168
Closed
kyu08 wants to merge 1 commit into
Closed
Conversation
When switching from full PR scope to a commit scope, only the global gitsigns base was updated to `sha^`. Buffers already displayed during full PR scope kept their buffer-local base (the PR base), which takes precedence over the global one, so gitsigns rendered the whole PR diff (all lines shown as added) instead of the single commit's changes. Mirror `apply_full_pr_scope` by looping over loaded buffers and calling `apply_gitsigns_base_for_buffer`, which already resolves the commit-scope base to `sha^`, overwriting the stale buffer-local bases. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
:FudeReviewScope で commit scope に切り替えた際、gitsigns の gutter が PR 全体の diff を表示してしまう不具合(Issue #167)を修正し、commit scope でも「その commit に対する正しい差分表示」を保つための変更です。
Changes:
apply_commit_scope実行時に、グローバル gitsigns base をsha^に更新した後、ロード済みバッファ全てへapply_gitsigns_base_for_buffer()を再適用してバッファローカル base を上書き- commit scope 時の gitsigns base 再適用について、
CLAUDE.mdのアーキテクチャ記述を更新
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lua/fude/scope.lua | commit scope 切替時に既存バッファの per-buffer gitsigns base を再適用し、stale な PR ベースが残る問題を解消 |
| CLAUDE.md | commit scope の gitsigns base 再適用についてドキュメントの説明を更新 |
Comment on lines
+677
to
+681
| -- Overwrite per-buffer bases left over from full PR scope: a buffer-local | ||
| -- base (set via change_base(_, false)) takes precedence over the global one, | ||
| -- so without this loop already-open buffers keep showing the PR-wide diff. | ||
| local init_mod = require("fude.init") | ||
| for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do |
Collaborator
Author
|
修正が確認できなかったが、 |
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.
概要
:FudeReviewScopeで特定commitに絞ると、gitsignsのgutterがそのcommitの変更行だけでなくPR全体のdiff(全行追加)を表示するバグを修正する。Fixes #167
原因
gitsignsの
change_base(base, false)(バッファローカル)はグローバルベースより優先される。full PR scope時に各バッファへPRベースがローカル設定されるが、commit scopeへ切り替えるapply_commit_scopeはグローバルベースをsha^に変えるだけで、既存バッファのローカルベースを掃除していなかった。結果、表示中バッファは古いPRベースとの差分を描き続けていた。previewの縦分割(
diffthis)はscopeごとにベース内容を再取得するため正しく表示され、]c/[cのhunkジャンプも正しく着地する。壊れていたのはgitsignsのgutterのみで、原因の切り分けと一致する。修正
apply_full_pr_scopeと対称に、グローバルベース設定後にロード済みバッファをループしてapply_gitsigns_base_for_bufferを呼び、各バッファのローカルベースをsha^に上書きする。同関数は既にcommit scopeを判定してsha^を使う(init_integration_spec.luaでカバー済み)。動作確認
make all通過(lint / format-check / test 44件成功、state-deps / purity / docs チェックOK)