mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-11-21 04:46:29 +03:00
If diff.mnemonicPrefix is set, pressing space on a line in the focused main view does nothing. The command log shows "Apply patch", but the line is not staged. Other commands that read a path out of the working tree's diff go wrong as well, such as jumping to a file. Building a custom patch from a commit's diff still works, because git uses mnemonic prefixes only when one side of the diff is the index or the working tree. With this config, the paths in the working tree's diff start with i/ and w/ instead of a/ and b/. We only strip a/ and b/, so the path we read out of the diff header is not a file of the files panel, and we skip the line without a message. Users who set the config want to see these prefixes, so keep them. Strip the first component of the path instead, whatever it is. `git apply` does the same by default, and ParseableDiffPrefixes makes sure there is such a component. A section without +++ and --- lines needs more than that, because we find the new path on its "diff --git" line by searching for " b/". Take the path from the "rename to" or "copy to" line instead where there is one. Otherwise the two paths on the "diff --git" line are the same. Split the line where the two halves match after stripping their prefixes, like `git apply` does. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>