Skip to content

Commit

Permalink
Clean up a few more changes we’ve made.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongrout committed Nov 21, 2019
1 parent 5c28be6 commit 1def5ff
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 39 deletions.
2 changes: 1 addition & 1 deletion packages/console/src/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ namespace Private {
if (executed) {
caption += `\nLast Execution: ${Time.format(executed.toISOString())}`;
}
panel.title.caption = caption;
panel.title.label = session.name;
panel.title.caption = caption;
} else {
panel.title.label = 'Console';
panel.title.caption = '';
Expand Down
36 changes: 18 additions & 18 deletions packages/console/src/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,38 +288,38 @@ export class CodeConsole extends Widget {
* should wait for the API to determine whether code being submitted is
* incomplete before attempting submission anyway. The default value is `250`.
*/
execute(force = false, timeout = EXECUTION_TIMEOUT): Promise<void> {
async execute(force = false, timeout = EXECUTION_TIMEOUT): Promise<void> {
if (this.session.kernel.status === 'dead') {
return Promise.resolve();
return;
}

const promptCell = this.promptCell;
if (!promptCell) {
return Promise.reject('Cannot execute without a prompt cell');
throw new Error('Cannot execute without a prompt cell');
}
promptCell.model.trusted = true;

if (force) {
// Create a new prompt cell before kernel execution to allow typeahead.
this.newPromptCell();
return this._execute(promptCell);
await this._execute(promptCell);
return;
}

// Check whether we should execute.
return this._shouldExecute(timeout).then(should => {
if (this.isDisposed) {
return;
}
if (should) {
// Create a new prompt cell before kernel execution to allow typeahead.
this.newPromptCell();
this.promptCell!.editor.focus();
return this._execute(promptCell);
} else {
// add a newline if we shouldn't execute
promptCell.editor.newIndentedLine();
}
});
let shouldExecute = await this._shouldExecute(timeout);
if (this.isDisposed) {
return;
}
if (shouldExecute) {
// Create a new prompt cell before kernel execution to allow typeahead.
this.newPromptCell();
this.promptCell!.editor.focus();
await this._execute(promptCell);
} else {
// add a newline if we shouldn't execute
promptCell.editor.newIndentedLine();
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/docregistry/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ export class Context<T extends DocumentRegistry.IModel>
/**
* Finish a saveAs operation given a new path.
*/
private _finishSaveAs(newPath: string): Promise<void> {
private async _finishSaveAs(newPath: string): Promise<void> {
this._path = newPath;
return this.session.session
?.setPath(newPath)
Expand Down
3 changes: 2 additions & 1 deletion packages/extensionmanager/src/companions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import { Dialog, showDialog } from '@jupyterlab/apputils';

import * as React from 'react';
import { KernelSpec } from '@jupyterlab/services/src/kernelspec';

import { KernelSpec } from '@jupyterlab/services';

/**
* An object representing a companion installation info.
Expand Down
7 changes: 5 additions & 2 deletions packages/extensionmanager/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@

import { VDomModel } from '@jupyterlab/apputils';

import { ServerConnection, ServiceManager } from '@jupyterlab/services';
import {
KernelSpec,
ServerConnection,
ServiceManager
} from '@jupyterlab/services';

import * as semver from 'semver';

Expand All @@ -18,7 +22,6 @@ import {
import { reportInstallError } from './dialog';

import { Searcher, ISearchResult, isJupyterOrg } from './query';
import { KernelSpec } from '@jupyterlab/services/src/kernelspec';

/**
* Information about an extension.
Expand Down
22 changes: 6 additions & 16 deletions packages/statusbar/src/defaults/kernelStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,25 +138,15 @@ export namespace KernelStatus {
return this._session;
}
set session(session: IClientSession | null) {
const oldSession = this._session;
if (oldSession !== null) {
oldSession.statusChanged.disconnect(this._onKernelStatusChanged);
oldSession.kernelChanged.disconnect(this._onKernelChanged);
}
this._session?.statusChanged.disconnect(this._onKernelStatusChanged);
this._session?.kernelChanged.disconnect(this._onKernelChanged);

const oldState = this._getAllState();
this._session = session;
if (this._session === null) {
this._kernelStatus = 'unknown';
this._kernelName = 'unknown';
} else {
this._kernelStatus = this._session.session.kernel.status;
this._kernelName = this._session.kernelDisplayName;

this._session.statusChanged.connect(this._onKernelStatusChanged);
this._session.kernelChanged.connect(this._onKernelChanged);
}

this._kernelStatus = session?.session?.kernel?.status ?? 'unknown';
this._kernelName = session?.kernelDisplayName ?? 'unknown';
session?.statusChanged.connect(this._onKernelStatusChanged);
session?.kernelChanged.connect(this._onKernelChanged);
this._triggerChange(oldState, this._getAllState());
}

Expand Down

0 comments on commit 1def5ff

Please sign in to comment.