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

don't use docmanager reload when opening gitignore #759

Merged
merged 5 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion binder/postBuild
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
pip install .
jupyter serverextension enable --sys-prefix --py nbgitpuller
jupyter lab build
jupyter lab build --dev-build=False --minimize=False --debug
6 changes: 0 additions & 6 deletions src/commandsAndMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { ITerminal } from '@jupyterlab/terminal';
import { CommandRegistry } from '@lumino/commands';
import { Menu } from '@lumino/widgets';
import { IGitExtension } from './tokens';
import { GitExtension } from './model';
import { GitCredentialsForm } from './widgets/CredentialsBox';
import { doGitClone } from './widgets/gitClone';
import { GitPullPushDialog, Operation } from './widgets/gitPushPull';
Expand Down Expand Up @@ -199,11 +198,6 @@ export function addCommands(
isEnabled: () => model.pathRepository !== null,
execute: async () => {
await model.ensureGitignore();
const gitModel = model as GitExtension;
await gitModel.commands.execute('docmanager:reload');
await gitModel.commands.execute('docmanager:open', {
path: model.getRelativeFilePath('.gitignore')
});
}
});

Expand Down
8 changes: 0 additions & 8 deletions src/components/FileList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,6 @@ export class FileList extends React.Component<IFileListProps, IFileListState> {
execute: async () => {
if (this.state.selectedFile) {
await this.props.model.ignore(this.state.selectedFile.to, false);
await this.props.model.commands.execute('docmanager:reload');
await this.props.model.commands.execute('docmanager:open', {
path: this.props.model.getRelativeFilePath('.gitignore')
});
}
}
});
Expand All @@ -187,10 +183,6 @@ export class FileList extends React.Component<IFileListProps, IFileListState> {
});
if (result.button.label === 'Ignore') {
await this.props.model.ignore(this.state.selectedFile.to, true);
await this.props.model.commands.execute('docmanager:reload');
await this.props.model.commands.execute('docmanager:open', {
path: this.props.model.getRelativeFilePath('.gitignore')
});
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,7 @@ export class GitExtension implements IGitExtension {
});

this.refreshStatus();
this._openGitignore();
return Promise.resolve(response);
}

Expand Down Expand Up @@ -1271,6 +1272,7 @@ export class GitExtension implements IGitExtension {
});

this.refreshStatus();
this._openGitignore();
return Promise.resolve(response);
}

Expand Down Expand Up @@ -1423,6 +1425,22 @@ export class GitExtension implements IGitExtension {
return this._taskID;
}

/**
* open new editor or show an existing editor of the
* .gitignore file. If the editor does not have unsaved changes
* then ensure the editor's content matches the file on disk
*/
private _openGitignore() {
if (this._docmanager) {
const widget = this._docmanager.openOrReveal(
this.getRelativeFilePath('.gitignore')
);
if (widget && !widget.context.model.dirty) {
widget.context.revert();
}
}
}

/**
* if file is open in JupyterLab find the widget and ensure the JupyterLab
* version matches the version on disk. Do nothing if the file has unsaved changes
Expand Down