Fix options initialisation in 2024.2+ #1043
Merged
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.
This PR will fix options initialisation in 2024.2 and above.
Options are initialised based on the currently selected editor (Vim "window"). In 2024.1, we could use
FileEditorManager.selectedTextEditor
to get the last selected text editor while creating a new editor. This value can no longer be relied upon in 2024.2, as the value is reset tonull
when a new editor (that will become the next selected editor) is being created.This meant we were always initialising window options based on the "fallback" window. Vim always has at least one window open, so there is always a window to initialise from. IntelliJ can close all windows, so we need to keep track of the options used by the window that was last to be closed - so if there are no open windows, we can initialise from the "fallback" window.
However, a further change in behaviour meant that we were updating this fallback window too frequently - whenever any window closed. This mostly mitigated the first problem, except for options that are mapped to IntelliJ settings, e.g.
'wrap'
. This lead to some tests for'wrap'
being disabled for 242.This PR will:
null
values don't cause trouble'wrap'
tests