diff --git a/binder/postBuild b/binder/postBuild index 233572629..c59547846 100644 --- a/binder/postBuild +++ b/binder/postBuild @@ -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 diff --git a/src/commandsAndMenu.ts b/src/commandsAndMenu.ts index 88fac284d..685f2de66 100644 --- a/src/commandsAndMenu.ts +++ b/src/commandsAndMenu.ts @@ -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'; @@ -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') - }); } }); diff --git a/src/components/FileList.tsx b/src/components/FileList.tsx index c97c1b154..c65d7313a 100644 --- a/src/components/FileList.tsx +++ b/src/components/FileList.tsx @@ -160,10 +160,6 @@ export class FileList extends React.Component { 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') - }); } } }); @@ -187,10 +183,6 @@ export class FileList extends React.Component { }); 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') - }); } } } diff --git a/src/model.ts b/src/model.ts index c09e0223f..b9944a5a0 100644 --- a/src/model.ts +++ b/src/model.ts @@ -1240,6 +1240,7 @@ export class GitExtension implements IGitExtension { }); this.refreshStatus(); + this._openGitignore(); return Promise.resolve(response); } @@ -1271,6 +1272,7 @@ export class GitExtension implements IGitExtension { }); this.refreshStatus(); + this._openGitignore(); return Promise.resolve(response); } @@ -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