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

Mitigate the negative effects of double x button in secondary, sidebar. #425

Merged
merged 4 commits into from
Jul 9, 2024

Conversation

filip131311
Copy link
Collaborator

Description

Because, secondary sidebar in vscode has a "close" button in top right corner, the user is faced with two "X" buttons that do different things; one closes the secondary sidebar and in effect hides our extension and the second closes our extension completely.

Solution

To mitigate the negative effects this PR overrides the command used to hide secondary sidebar and closes React native IDE completely before hiding it, that makes two buttons perform similar actions instead of doing two different things, which is an improvement.

Hiding the second button

The natural question to ask is why can't we disable, our "close RNIDE" button when IDE is in secondary sidebar. Unfortunately there is now reliable way to check in which sideBar the viewContainer contributed by an extension is located at any given time. There is a closed issue on that topic here. One workaround for that would be to check if context key "activeAuxiliary" has value matching our extension contributed viewContainer, because since it is an activeAuxiliary it has to be in Auxiliary SideBar, unfortunately the id of Extension contributed view Containers is randomly generated, you can read the code here the first relevant line is 502.

There is hope of discovering the generated viewContainer id by checking the activeAxiliary and activeViewlet context fields while we know about its location, but it would require a getContext() API that is not currently implemented, an active issue on that can be found here.

Copy link

vercel bot commented Jul 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-native-ide ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 9, 2024 6:22pm


const isIDEPanelVisible = SidePanelViewProvider.currentProvider?.view?.visible;

// if closing of Auxiliary bar affected the visibility of SidePanelView, we assume that it means that it was pined to the secondary sidebar.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: pinned.

@@ -136,6 +137,35 @@ export async function activate(context: ExtensionContext) {
commands.registerCommand("RNIDE.diagnose", diagnoseWorkspaceStructure)
);

async function closeAuxiliaryBar(registeredCommandDisposable: Disposable) {
registeredCommandDisposable.dispose(); // must dispose to avoid endless loops
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: may be more readable with helper like interceptCommand(name: string, fn: () -> Disposable): Disposable.

@filip131311 filip131311 merged commit 6d4fe0a into main Jul 9, 2024
3 checks passed
@filip131311 filip131311 deleted the @Filip131311/FixDoubleX branch July 9, 2024 18:30
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