Skip to content

Conversation

@jofserponcon
Copy link

@jofserponcon jofserponcon commented Apr 5, 2025

To fix the following scenario:

1- diff 2 directories
2- open a differ
3- Enter/o outside of the differ or only in range (e.g., on any of the 6 first lines)
4- open again the same differ line as in 2-

(Neovim 0.10.4 on MacOS)

=> The diff state is then broken:

  • the ex command line height is now weirdly increased (I havent tracked why)
  • it's now basically impossible to reenter a stable state, by opening a new differ or only in line

It seems to me that in the function DirDiffOpen(), we try too late to manage the case where we hit a non diff/only line.

After 3-:

  • b:currentDiff refers to the new non-diff line
  • s:FilenameA and s:FilenameB now contain the names of directories [A] and [B] respectively.

On 4-, when we enter DirDiffOpen() again, we don't exit the function right away because b:currentDiff does not match. Why not.

However, when we finally enter this block, the call to bufnr(directory A) returns the same buffer number as that of the actual file A in diff. So, we basically delete the buffer we just entered.

I think that the easiest is, during step 3, leave things as immaculate as possible:
like, if we see that we are not on a differ or only line, we just leave, which is what I propose in this PR.

@jofserponcon jofserponcon changed the title Fix plugin lose track of current state Fix plugin loses track of current state Apr 5, 2025
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