patch 9.1.1600: using diff anchors with hidden buffers fails silently

Problem:  diff: using diff anchors with hidden buffers fails silently
Solution: Give specific error message for diff anchors when using hidden
          buffers (Yee Cheng Chin).

Diff anchors currently will fail to parse if a buffer used for diff'ing
is hidden. Previously it would just fail as the code assumes it would
not happen normally, but this is actually possible to do if `closeoff`
and `hideoff` are not set in diffopt. Git's default diff tool "vimdiff3"
also takes advantage of this.

This fix this properly would require the `{address}` parser to be
smarter about whether a particular address relies on window position or
not (e.g. the `'.` address requires an active window, but `'a` or `1234`
do not). Since hidden diff buffers seem relatively niche, just provide a
better error message / documentation for now. This could be improved
later if there's a demand for it.

related: #17615
closes: #17904

Signed-off-by: Yee Cheng Chin <ychin.git@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Yee Cheng Chin
2025-08-07 15:33:34 +02:00
committed by Christian Brabandt
parent 589aa284f6
commit cad3b2421d
7 changed files with 27 additions and 4 deletions

5
src/po/vim.pot generated
View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-07-25 19:14+0200\n"
"POT-Creation-Date: 2025-08-07 15:32+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -8803,6 +8803,9 @@ msgstr ""
msgid "E1561: Duplicate type variable name: %s"
msgstr ""
msgid "E1562: Diff anchors cannot be used with hidden diff windows"
msgstr ""
#. type of cmdline window or 0
#. result of cmdline window or 0
#. buffer of cmdline window or NULL