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

Extension forgets it is in a git directory when moving to opposite side bar #876

Closed
ca-scribner opened this issue Feb 19, 2021 · 2 comments · Fixed by #880
Closed

Extension forgets it is in a git directory when moving to opposite side bar #876

ca-scribner opened this issue Feb 19, 2021 · 2 comments · Fixed by #880
Labels

Comments

@ca-scribner
Copy link

Description

Moving the extension from one sidebar to another causes it to forget that the current directory is git-backed, and it will not recover until moving up above the current directory and back in.

Reproduce

From a git-backed directory:

  • left click extension (confirm it shows git-backed directory)
  • right click on the extension in left side bar and move to other sidebar
  • (extension will show a non-git-backed directory)
  • Browsing in file browser deeper into path will not resolve
  • Browsing up in filetree until we're out of the git dir, then back into it, will make things work again

Expected behavior

That extension does not lose track of it being in a git directory when switching side bar side, or at least can quickly recover.

@krassowski
Copy link
Member

I can confirm this issue.

@ktaletsk
Copy link
Contributor

Okay, let's try take a shot at this. The bug is due to pathRepository not being set correctly in the model.

GitPanel.render() checks if GitPanel.state.repository is not null and only then renders the panel. If it is null, we get _renderWarning panel. This is what happens in the current bug behavior after switching the sidebar side.

GitPanel.componentDidMount() updates GitPanel.state.repository variable upon receiving signal from model.repositoryChanged. Signal is emitted by the GitExtension.pathRepository property setter. Currently, the property is set only in handful of places: when running git init, when application is restored or the filebrowser path is changed. However, it is not called when sidebar side for JupyterLab-git is changed and that cause the current bug.

The fix I came up with is to force change the repository in GitPanel.componentDidMount() by setting the state.repository with model.pathRepository. Since GitPanel.componentDidMount() also runs after changing the sidebar side, it fixes the problem, but does not affect existing signalling for repositoryChanged.

It might not be an optimal fix, but hopefully my analysis could help come up with a better fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants