Sessions do not preserve script version for option holding expressions#20696
Open
illia-bobyr wants to merge 1 commit into
Open
Sessions do not preserve script version for option holding expressions#20696illia-bobyr wants to merge 1 commit into
illia-bobyr wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 necessarySince 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.