Skip to content
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

Fix options initialisation in 2024.2+ #1043

Merged
merged 4 commits into from
Nov 22, 2024

Conversation

citizenmatt
Copy link
Member

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 to null 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:

  • Update option tests to make them easier to understand and to ensure that the fallback window is updated correctly. This should help diagnose similar problems if behaviour changes in the future
  • Change the method of updating the fallback window so it's only updated when the last window in a project is closed
  • Start manually tracking the last selected editor/window so that unexpected null values don't cause trouble
  • Reinstate disabled 'wrap' tests

Expanded to assert changes on all open windows, and formatted to make it a little easier to read/comprehend what's being tested
The assumption for selection change events is no longer valid in 242, so switch approach to checking when editors are released
This is important for initialising options. We can't rely on FileEditorManager.selectedTextEditor, as 2024.2 changed behaviour to reset to null during creation of a new editor. This fixes tests (and option initialisation) for 242.
@AlexPl292
Copy link
Member

Awesome, thank you for your work!

@AlexPl292 AlexPl292 merged commit 8da15b8 into JetBrains:master Nov 22, 2024
4 checks passed
@citizenmatt citizenmatt deleted the bugfix/options-init branch November 25, 2024 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants