Skip to content

diff: wrong folds for diff window in another tab page - #21678

Closed
glepnir wants to merge 1 commit into
vim:masterfrom
glepnir:diff_tp
Closed

glepnir wants to merge 1 commit into
vim:masterfrom
glepnir:diff_tp

Conversation

@glepnir

@glepnir glepnir commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Problem: Folds of a diff window in another tab page are computed with
the diff of the current tab page and are not updated when
that tab page is entered.
Solution: Use the tab page of the window in diff_infold().

related: neovim/neovim#42576

AI assistance

  • AI involvement is disclosed in the commit message
  • No AI was used

Checklist

  • The commit message follows the Problem/Solution form above
  • Signed-off-by: trailer is present (git commit -s), recommended but not required

Tests

  • Tests were added
  • Existing tests cover the change
  • The change cannot be tested (explain below)

Documentation

  • Documentation under runtime/doc/ was updated
  • No documentation update is needed

Anything reviewers should know

Problem:  Folds of a diff window in another tab page are computed with
          the diff of the current tab page and are not updated when
          that tab page is entered.
Solution: Use the tab page of the window in diff_infold().
@chrisbra

chrisbra commented Nov 5, 2026

Copy link
Copy Markdown
Member

thanks, makes sense

@chrisbra

chrisbra commented Nov 5, 2026

Copy link
Copy Markdown
Member

hm, the test does not fail unpatched, but setbufline() makes it fail instead.

@chrisbra chrisbra closed this in 1f81e52 Nov 5, 2026
zeertzjq added a commit to neovim/neovim that referenced this pull request Nov 6, 2026
…page (#42714)

Problem:  Folds of a diff window in another tab page are computed with
          the diff of the current tab page and are not updated when
          that tab page is entered.
Solution: Use the tab page of the window in diff_infold() (glepnir).

closes: vim/vim#21678

vim/vim@1f81e52

Co-authored-by: glepnir <[email protected]>
@glepnir
glepnir deleted the diff_tp branch November 6, 2026 03:43
@h-east

h-east commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Since this patch, Test_crash1_2 fails on Linux and macOS in CI. The
"crash 6" case (the Xdiff script) times out in WaitFor(), also when
it is run again as a flaky test:

9.2.1295: https://github.com/vim/vim/actions/runs/42090810681
current master: https://github.com/vim/vim/actions/runs/42116805200

In the run for 9.2.1294 the test jobs that got past the build step
passed, including Test_crash1_2.

@h-east

h-east commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

I ran it locally: Vim does not crash, the "crash 6" case is slow.
In an 80x24 terminal it takes 5.5 to 6.3 seconds on the current
master, longer than the 5 seconds WaitFor() waits, and 0.8 seconds
with this patch reverted.

The slowdown comes from the win_valid() call added to diff_infold(),
which walks the window list each time diff_infold() is called. For
a test I changed only this line in diff_infold() and kept the rest
of this patch:

-    tp = win_valid(wp) ? curtab : win_find_tabpage(wp);
+    tp = curtab;

With that, the case takes 0.8 seconds again.

@glepnir

glepnir commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

Thanks. Fixed in #21782 by looking up the tab page once per fold update.

chrisbra pushed a commit that referenced this pull request Nov 8, 2026
Problem:  diff_infold() checks the tab page of the window for every
          line, which is slow with many windows (Test_crash1_2 times out
          after v9.2.1295).
Solution: Find the tab page once in foldUpdateIEMS() and pass it to
          diff_infold() (glephunter).

related: #21678
closes:  #21782

Signed-off-by: glepnir <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
h-east added a commit to h-east/viai that referenced this pull request Nov 8, 2026
Problem:  diff_infold() checks the tab page of the window for every
          line, which is slow with many windows (Test_crash1_2 times out
          after v9.2.1295).
Solution: Find the tab page once in foldUpdateIEMS() and pass it to
          diff_infold() (glephunter).

vim/vim@34b846a

related: vim/vim#21678
closes:  vim/vim#21782

Co-authored-by: glepnir <[email protected]>
Signed-off-by: Hirohito Higashi <[email protected]>
h-east added a commit to h-east/viai that referenced this pull request Nov 8, 2026
…page

Problem:  Folds of a diff window in another tab page are computed with
          the diff of the current tab page and are not updated when
          that tab page is entered.
Solution: Use the tab page of the window in diff_infold() (glepnir).

vim/vim@1f81e52

closes: vim/vim#21678
closes: viai-editor#211

Co-authored-by: glepnir <[email protected]>
Signed-off-by: Hirohito Higashi <[email protected]>
h-east added a commit to h-east/viai that referenced this pull request Nov 8, 2026
Problem:  diff_infold() checks the tab page of the window for every
          line, which is slow with many windows (Test_crash1_2 times out
          after v9.2.1295).
Solution: Find the tab page once in foldUpdateIEMS() and pass it to
          diff_infold() (glephunter).

vim/vim@34b846a

related: vim/vim#21678
closes:  vim/vim#21782
closes: viai-editor#211

Co-authored-by: glepnir <[email protected]>
Signed-off-by: Hirohito Higashi <[email protected]>
h-east added a commit to viai-editor/viai that referenced this pull request Nov 8, 2026
…page

Problem:  Folds of a diff window in another tab page are computed with
          the diff of the current tab page and are not updated when
          that tab page is entered.
Solution: Use the tab page of the window in diff_infold() (glepnir).

vim/vim@1f81e52

closes: vim/vim#21678
closes: #211

Co-authored-by: glepnir <[email protected]>
Signed-off-by: Hirohito Higashi <[email protected]>
h-east added a commit to viai-editor/viai that referenced this pull request Nov 8, 2026
Problem:  diff_infold() checks the tab page of the window for every
          line, which is slow with many windows (Test_crash1_2 times out
          after v9.2.1295).
Solution: Find the tab page once in foldUpdateIEMS() and pass it to
          diff_infold() (glephunter).

vim/vim@34b846a

related: vim/vim#21678
closes:  vim/vim#21782
closes: #211

Co-authored-by: glepnir <[email protected]>
Signed-off-by: Hirohito Higashi <[email protected]>
zeertzjq added a commit to neovim/neovim that referenced this pull request Nov 9, 2026
Problem:  diff_infold() checks the tab page of the window for every
          line, which is slow with many windows (Test_crash1_2 times out
          after v9.2.1295).
Solution: Find the tab page once in foldUpdateIEMS() and pass it to
          diff_infold() (glephunter).

related: vim/vim#21678
closes:  vim/vim#21782

vim/vim@34b846a

Co-authored-by: glepnir <[email protected]>
Rational-Idiot pushed a commit to Rational-Idiot/neovim that referenced this pull request Nov 13, 2026
…42756)

Problem:  diff_infold() checks the tab page of the window for every
          line, which is slow with many windows (Test_crash1_2 times out
          after v9.2.1295).
Solution: Find the tab page once in foldUpdateIEMS() and pass it to
          diff_infold() (glephunter).

related: vim/vim#21678
closes:  vim/vim#21782

vim/vim@34b846a

Co-authored-by: glepnir <[email protected]>
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