Problem: Sessions do not preserve script version for option holding
expressions
Solution: Remember script version for string options, and add a
":legacy" prefix for ":set"/":setlocal" calls when necessary
Since patch 9.2.0579 (":mksession, :mkview and :mkvimrc emit legacy Vim script") session files are marked as Vim9 script. A few options have Vim expressions as their values. When inserted their values literally into a Vim9 script, these expressions are now evaluated as Vim9 expressions. But the original value might have been set by a legacy script.
In order to be backward compatible and not break most of the existing file type plugin scripts, we need to consider the script version of the option value. If an option was set in a legacy script, or via "legacy set"/"legacy setlocal", we need to restore it using the "legacy" prefix as well.
Options are not marked as expression options, vs string options, vs bool options. We only know if an option is a bool, number or a string option. It seems safe to set bool and number options using Vim9 semantics. But for string options we do not know if an option value is a Vim expression. And so, if it was set by a legacy script we just use a conservative approach and prefix the "set" or "setlocal" command with "legacy" for all string options set in a legacy context.
https://github.com/vim/vim/pull/20696
(3 files)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()