patch 9.1.0147: Cannot keep a buffer focused in a window

Problem:  Cannot keep a buffer focused in a window
          (Amit Levy)
Solution: Add the 'winfixbuf' window-local option
          (Colin Kennedy)

fixes:  #6445
closes: #13903

Signed-off-by: Colin Kennedy <colinvfx@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/runtime/doc/message.txt b/runtime/doc/message.txt
index 133d47a..5848074 100644
--- a/runtime/doc/message.txt
+++ b/runtime/doc/message.txt
@@ -1,4 +1,4 @@
-*message.txt*   For Vim version 9.1.  Last change: 2023 Dec 20
+*message.txt*   For Vim version 9.1.  Last change: 2024 Mar 03
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -122,6 +122,13 @@
 You cannot have two buffers with exactly the same name.  This includes the
 path leading to the file.
 
+							*E1513* >
+  Cannot edit buffer. 'winfixbuf' is enabled
+
+If a window has 'winfixbuf' enabled, you cannot change that window's current
+buffer. You need to set 'nowinfixbuf' before continuing. You may use [!] to
+force the window to switch buffers, if your command supports it.
+
 							*E72*
   Close error on swap file ~
 
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 210bfdc..e38aa81 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -1,4 +1,4 @@
-*options.txt*	For Vim version 9.1.  Last change: 2024 Feb 24
+*options.txt*	For Vim version 9.1.  Last change: 2024 Mar 03
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
@@ -8021,6 +8021,8 @@
 			"split" when both are present.
 	   uselast	If included, jump to the previously used window when
 			jumping to errors with |quickfix| commands.
+	If a window has 'winfixbuf' enabled, 'switchbuf' is currently not
+	applied to the split window.
 
 						*'synmaxcol'* *'smc'*
 'synmaxcol' 'smc'	number	(default 3000)
@@ -9471,6 +9473,15 @@
 	Note: Do not confuse this with the height of the Vim window, use
 	'lines' for that.
 
+						*'winfixbuf'*
+'winfixbuf' 'wfb'	boolean	(default off)
+			local to window
+	If enabled, the buffer and any window that displays it are paired.
+	For example, attempting to change the buffer with |:edit| will fail.
+	Other commands which change a window's buffer such as |:cnext| will
+	also skip any window with 'winfixbuf' enabled. However if a command
+	has an "!" option, a window can be forced to switch buffers.
+
 			*'winfixheight'* *'wfh'* *'nowinfixheight'* *'nowfh'*
 'winfixheight' 'wfh'	boolean	(default off)
 			local to window  |local-noglobal|
diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt
index dcbb520..517fa30 100644
--- a/runtime/doc/quickref.txt
+++ b/runtime/doc/quickref.txt
@@ -1,4 +1,4 @@
-*quickref.txt*  For Vim version 9.1.  Last change: 2023 Dec 05
+*quickref.txt*  For Vim version 9.1.  Last change: 2024 Mar 03
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -1005,6 +1005,7 @@
 'winaltkeys'	  'wak'     when the windows system handles ALT keys
 'wincolor'	  'wcr'	    window-local highlighting
 'window'	  'wi'	    nr of lines to scroll for CTRL-F and CTRL-B
+'winfixbuf'	  'wfb'     keep window focused on a single buffer
 'winfixheight'	  'wfh'     keep window height when opening/closing windows
 'winfixwidth'	  'wfw'     keep window width when opening/closing windows
 'winheight'	  'wh'	    minimum number of lines for the current window
diff --git a/runtime/doc/tags b/runtime/doc/tags
index 8af0b57..efecedf 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -1294,6 +1294,7 @@
 'winaltkeys'	options.txt	/*'winaltkeys'*
 'wincolor'	options.txt	/*'wincolor'*
 'window'	options.txt	/*'window'*
+'winfixbuf'	options.txt	/*'winfixbuf'*
 'winfixheight'	options.txt	/*'winfixheight'*
 'winfixwidth'	options.txt	/*'winfixwidth'*
 'winheight'	options.txt	/*'winheight'*
@@ -4541,6 +4542,7 @@
 E1510	change.txt	/*E1510*
 E1511	options.txt	/*E1511*
 E1512	options.txt	/*E1512*
+E1513	message.txt	/*E1513*
 E152	helphelp.txt	/*E152*
 E153	helphelp.txt	/*E153*
 E154	helphelp.txt	/*E154*
diff --git a/runtime/doc/tagsrch.txt b/runtime/doc/tagsrch.txt
index aa7b9dd..ce6d446 100644
--- a/runtime/doc/tagsrch.txt
+++ b/runtime/doc/tagsrch.txt
@@ -1,4 +1,4 @@
-*tagsrch.txt*   For Vim version 9.1.  Last change: 2023 Feb 13
+*tagsrch.txt*   For Vim version 9.1.  Last change: 2024 Mar 03
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -409,17 +409,22 @@
 performed actions depend on whether the current file was changed, whether a !
 is added to the command and on the 'autowrite' option:
 
-  tag in       file	   autowrite			~
-current file  changed	!   option	  action	~
------------------------------------------------------------------------------
-    yes		 x	x     x	  goto tag
-    no		 no	x     x	  read other file, goto tag
-    no		yes    yes    x   abandon current file, read other file, goto
-				  tag
-    no		yes	no    on  write current file, read other file, goto
-				  tag
-    no		yes	no   off  fail
------------------------------------------------------------------------------
+  tag in       file	                autowrite			~
+current file  changed	!   winfixbuf   option	      action	~
+ -----------------------------------------------------------------------------
+    yes		x	x      no         x         goto tag
+    no		no	x      no         x         read other file, goto tag
+    no		yes	yes    no         x         abandon current file,
+						    read other file, goto tag
+    no		yes	no     no         on        write current file,
+						    read other file, goto tag
+    no		yes	no     no         off       fail
+    yes		x	yes    x          x         goto tag
+    no		no	no     yes        x         fail
+    no		yes	no     yes        x         fail
+    no		yes	no     yes        on        fail
+    no		yes	no     yes        off       fail
+ -----------------------------------------------------------------------------
 
 - If the tag is in the current file, the command will always work.
 - If the tag is in another file and the current file was not changed, the
@@ -435,6 +440,8 @@
   the changes, use the ":w" command and then use ":tag" without an argument.
   This works because the tag is put on the stack anyway.  If you want to lose
   the changes you can use the ":tag!" command.
+- If the tag is in another file and the window includes 'winfixbuf', the
+  command will fail. If the tag is in the same file then it may succeed.
 
 							*tag-security*
 Note that Vim forbids some commands, for security reasons.  This works like
diff --git a/runtime/doc/version9.txt b/runtime/doc/version9.txt
index 7b9a366..7947cb2 100644
--- a/runtime/doc/version9.txt
+++ b/runtime/doc/version9.txt
@@ -1,4 +1,4 @@
-*version9.txt*  For Vim version 9.1.  Last change: 2024 Feb 21
+*version9.txt*  For Vim version 9.1.  Last change: 2024 Mar 03
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -41575,6 +41575,8 @@
 
 Options: ~
 
+'winfixbuf'		Keep buffer focused in a window
+
 ==============================================================================
 INCOMPATIBLE CHANGES				*incompatible-9.2*
 
diff --git a/runtime/optwin.vim b/runtime/optwin.vim
index 6e133ce..d3e1605 100644
--- a/runtime/optwin.vim
+++ b/runtime/optwin.vim
@@ -482,6 +482,7 @@
   call <SID>AddOption("statusline", gettext("alternate format to be used for a status line"))
   call <SID>OptionG("stl", &stl)
 endif
+call append("$", "\t" .. s:local_to_window)
 call <SID>AddOption("equalalways", gettext("make all windows the same size when adding/removing windows"))
 call <SID>BinOptionG("ea", &ea)
 call <SID>AddOption("eadirection", gettext("in which direction 'equalalways' works: \"ver\", \"hor\" or \"both\""))
@@ -490,6 +491,8 @@
 call append("$", " \tset wh=" . &wh)
 call <SID>AddOption("winminheight", gettext("minimal number of lines used for any window"))
 call append("$", " \tset wmh=" . &wmh)
+call <SID>AddOption("winfixbuf", gettext("keep window focused on a single buffer"))
+call <SID>OptionG("wfb", &wfb)
 call <SID>AddOption("winfixheight", gettext("keep the height of the window"))
 call append("$", "\t" .. s:local_to_window)
 call <SID>BinOptionL("wfh")