fix: guard against undefined currentProject in sidebar decoration provider - #939
Open
wahajahmed010 wants to merge 1 commit into
Open
fix: guard against undefined currentProject in sidebar decoration provider#939wahajahmed010 wants to merge 1 commit into
wahajahmed010 wants to merge 1 commit into
Conversation
…vider Container.currentProject can be undefined when no saved project matches the currently open folder (e.g. a window opened on a folder not in the Project Manager list, or during startup before the current project is resolved). Accessing .rootPath on undefined throws a TypeError that floods the Extension Host and can cause it to terminate. Closes alefragnani#938
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.
Description
Fixes a crash in the sidebar decoration provider when
Container.currentProjectisundefined.Root cause:
Container._currentProjectis declared but never initialized, so it remainsundefinedwhenever no saved project matches the currently open folder (e.g. a window opened on a folder not in the Project Manager list, or during startup before the current project is resolved). TheprovideFileDecorationmethod indecoration.tsaccessed.rootPathonContainer.currentProjectwithout a null guard, throwing:Because
provideFileDecorationis invoked repeatedly (once per tree item), the errors flood the Extension Host and can cause it to terminate.Fix: Added a truthiness check for
Container.currentProjectbefore accessing.rootPath.Changes
src/sidebar/decoration.ts: GuardContainer.currentProjectwith a null check before accessing.rootPathTesting
currentProjectis undefined, the function returnsundefined(no decoration), which is the correct fallback behaviorCloses #938
This contribution was created with assistance from an AI coding agent (Buck/OpenClaw). The fix was reviewed and validated for correctness.