Maintenance: OutputPanelScopeImpl - Fix stale outputPanel reference#1586
Open
claude[bot] wants to merge 1 commit intomasterfrom
Open
Maintenance: OutputPanelScopeImpl - Fix stale outputPanel reference#1586claude[bot] wants to merge 1 commit intomasterfrom
claude[bot] wants to merge 1 commit intomasterfrom
Conversation
`outputPanel` was a `val` on the singleton object, meaning it was
captured once at initialization time via `getOrCreate`. After the
panel became inactive (e.g., user dismissed it or the associated
editor was closed), all subsequent `outputPanel { ... }` calls
continued to operate on this stale panel.
Change `outputPanel` to a computed property (`get()`) so it always
delegates to `injector.outputPanel.getOrCreate(...)`, which either
returns the current active panel or creates a fresh one for the
currently focused editor.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
de053c4 to
9b20d56
Compare
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.
Summary
vim-engine/src/main/kotlin/com/maddyhome/idea/vim/thinapi/OutputPanelScopeImpl.ktVimOutputPanelServiceBase.kt), which led to inspecting the relatedOutputPanelScopeImplIssue Found
When
OutputPanelScopeImplwas changed from aclassto anobjectsingleton (commit04d9282fb), theoutputPanelproperty was left as a backing field:Since this is a Kotlin
object, this field is initialized once when the singleton is first accessed. All subsequent calls tosetText,appendText,clearText, etc. reuse the same staleVimOutputPanelinstance — even if:q, or listeners inVimListenerManager/MotionGroupcallingclose())Before the class→object change,
OutputPanelScopeImpl()was instantiated fresh for eachapi.outputPanel { ... }call, sogetOrCreatewas called each time. After the change, that fresh evaluation only happens once.Change Made
Made
outputPanela computed property with an explicitget(), consistent with:vimEditorandvimContextin the same classoptionGroupinOptionScopeImplThis ensures each method call gets the current active panel (or creates a new one for the currently focused editor) via the existing
getOrCreatemechanism.Why This Improves the Code
object