patch 8.2.3901: Vim9: Cannot set 'cpo' in main .vimrc if using Vim9 script
Problem: Vim9: Cannot set 'cpo' in main .vimrc if using Vim9 script.
Solution: Do not restore 'cpo' at the end of the main .vimrc.
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index f0939e6..e8773d9 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -2133,8 +2133,18 @@
Commas can be added for readability.
To avoid problems with flags that are added in the future, use the
"+=" and "-=" feature of ":set" |add-option-flags|.
+
NOTE: This option is set to the Vi default value when 'compatible' is
set and to the Vim default value when 'compatible' is reset.
+
+ NOTE: In a |Vim9| script, when `vim9script` is encountered, the value
+ is saved, 'cpoptions' is set to the Vim default, and the saved value
+ is restored at the end of the script. Changes to the value of
+ 'cpoptions' will be applied to the saved value, but keep in mind that
+ removing a flag that is not present when 'cpoptions' is changed has no
+ effect. In the |.vimrc| file the value is not restored, thus using
+ `vim9script` in the |.vimrc| file results in using the Vim default.
+
NOTE: This option is set to the POSIX default value at startup when
the Vi default value would be used and the $VIM_POSIX environment
variable exists |posix|. This means Vim tries to behave like the
diff --git a/runtime/doc/vim9.txt b/runtime/doc/vim9.txt
index 6c142a4..ced0c7d 100644
--- a/runtime/doc/vim9.txt
+++ b/runtime/doc/vim9.txt
@@ -1402,6 +1402,7 @@
The original value of 'cpoptions' is restored at the end of the script, while
flags added or removed in the script are also added to or removed from the
original value to get the same effect. The order of flags may change.
+In the |vimrc| file sourced on startup this does not happen.
*vim9-mix*
There is one way to use both legacy and Vim9 syntax in one script file: >