-
Notifications
You must be signed in to change notification settings - Fork 750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support per-window "global" values for local-to-window options #697
Merged
AlexPl292
merged 15 commits into
JetBrains:master
from
citizenmatt:feature/per-window-global-options
Sep 11, 2023
Merged
Support per-window "global" values for local-to-window options #697
AlexPl292
merged 15 commits into
JetBrains:master
from
citizenmatt:feature/per-window-global-options
Sep 11, 2023
Conversation
This file contains 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
Getting the effective IJ options would allow access to Vim global and IJ global, but not Vim effective. IntelliJ specific options are now a separate hierarchy, so the Vim effective and IJ effective accessors now simply access all Vim or all IJ options.
For local-to-window options
Subsequent initialisation will be treated like EDIT
This is primarily to avoid instantiating inactive extensions when resetting all options back to default values, which sets extensions inactive. It applies to global and local options, but not to global-local. The notifications for global-local options are already complex, as they can be reacting to changes to both the global and local value, and only notifying editors that are affected.
Just pushed an extra commit to only notify changes for options that have actually changed. This is primarily to avoid instantiating extensions when resetting the extension's option – it will instantiate the extension just to mark it inactive. |
Awesome work! Merged, thank you! |
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.
When an option is set in Vim with
:set
, Vim will set the local/effective value of the option and also sets a global value. When opening a new window or editing a new buffer in the current window, Vim will (re)initialise options by copying the global value to the new window's effective options. This means last-write-wins. For non-user-visible (local-to-buffer) options such as'fileencoding'
this makes sense - the user sees the behaviour set with the last write, regardless of which window it was actually set in. For user-visible options such as'relativenumber'
, this is less intuitive. The user will expect to see the same value as currently used in the current/opening window, not the last globally set value (ignoring explicitly local values set with:setlocal
). In order to do this, Vim's local-to-window options maintain a per-window "global" value rather than an application wide global value (as used by local-to-buffer options).This PR adds support for per-window "global" values for local-to-window options to IdeaVim. It can be seen in action by setting different values of the
'relativenumber'
local-to-window option and using that to open new windows. IdeaVim will open the new window based on the settings in the current window, so the same look-and-feel of the opening window is maintained, similar to Vim.This behaviour will be used by all local-to-window options, including the
'wrap'
option, which will be added next - user-visible options will be correctly copied to a new window, from the opening window, providing Vim compatible, intuitive option values.It also:
:edit {file}
. (IntelliJ implements preview tabs and reusing tabs by simply opening a new tab and closing the previous tab). The previous PR already implemented initialising new windows from the current/opening window.~/.ideavimrc
file. This is used to capture option state and apply it to the first opened editor. Vim will initialisevimrc
files in the context of the initial window and buffer, and now IdeaVim will do so too, even if there are no editors open at the time of IDE startup, or if plugin initialisation is delayed. This can be seen by the use ofsetlocal
in~/.ideavimrc
.OptionAccessScope.GLOBAL
from a singleton object to also requiring aVimEditor
instance, likeLOCAL
andEFFECTIVE
. This is necessary to be able to access per-window "global" values of local-to-window options. It is possible to passnull
as this editor, but this is only valid when accessing global options and only applicable if an editor isn't available. Generally speaking, you should always pass an editor toGLOBAL
.OptionScope
toOptionAccessScope
to avoid confusion withOptionDeclaredScope
, and fixing some minor implementation details of adding/removing values from string and string list options.