Skip to content

Commit 0d96d3a

Browse files
committed
Cherry-pick 26a7b9c
1 parent f7a4d53 commit 0d96d3a

5 files changed

Lines changed: 24 additions & 15 deletions

File tree

news/2 Fixes/4853.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix status bar when using Live Share or just starting the Python Interactive window.

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
"DataScience.liveShareSyncFailure": "Synchronization failure during live share startup.",
158158
"DataScience.liveShareServiceFailure": "Failure starting '{0}' service during live share connection.",
159159
"DataScience.documentMismatch": "Cannot run cells, duplicate documents for {0} found.",
160+
"DataScience.pythonInteractiveCreateFailed": "Failure to create a 'Python Interactive' window. Try reinstalling the Python extension.",
160161
"diagnostics.warnSourceMaps": "Source map support is enabled in the Python Extension, this will adversely impact performance of the extension.",
161162
"diagnostics.disableSourceMaps": "Disable Source Map Support",
162163
"diagnostics.warnBeforeEnablingSourceMaps": "Enabling source map support in the Python Extension will adversely impact performance of the extension.",

src/client/common/utils/localize.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ export namespace DataScience {
142142
export const liveShareServiceFailure = localize('DataScience.liveShareServiceFailure', 'Failure starting \'{0}\' service during live share connection.');
143143
export const documentMismatch = localize('DataScience.documentMismatch', 'Cannot run cells, duplicate documents for {0} found.');
144144
export const jupyterGetVariablesBadResults = localize('DataScience.jupyterGetVariablesBadResults', 'Failed to fetch variable info from the Jupyter server.');
145+
export const pythonInteractiveCreateFailed = localize('DataScience.pythonInteractiveCreateFailed', 'Failure to create a \'Python Interactive\' window. Try reinstalling the Python extension.');
146+
145147
}
146148

147149
export namespace DebugConfigurationPrompts {

src/client/datascience/historyProvider.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import * as vsls from 'vsls/vscode';
99
import { ILiveShareApi, IWorkspaceService } from '../common/application/types';
1010
import { IAsyncDisposable, IAsyncDisposableRegistry, IConfigurationService, IDisposableRegistry } from '../common/types';
1111
import { createDeferred, Deferred } from '../common/utils/async';
12+
import * as localize from '../common/utils/localize';
1213
import { IServiceContainer } from '../ioc/types';
1314
import { Identifiers, LiveShare, LiveShareCommands, Settings } from './constants';
1415
import { PostOffice } from './liveshare/postOffice';
@@ -64,14 +65,18 @@ export class HistoryProvider implements IHistoryProvider, IAsyncDisposable {
6465

6566
public async getOrCreateActive() : Promise<IHistory> {
6667
if (!this.activeHistory) {
67-
this.activeHistory = await this.create();
68+
await this.create();
6869
}
6970

7071
// Make sure all other providers have an active history.
7172
await this.synchronizeCreate();
7273

7374
// Now that all of our peers have sync'd, return the history to use.
74-
return this.activeHistory;
75+
if (this.activeHistory) {
76+
return this.activeHistory;
77+
}
78+
79+
throw new Error(localize.DataScience.pythonInteractiveCreateFailed());
7580
}
7681

7782
public async getNotebookOptions() : Promise<INotebookServerOptions> {
@@ -107,15 +112,16 @@ export class HistoryProvider implements IHistoryProvider, IAsyncDisposable {
107112
return this.postOffice.dispose();
108113
}
109114

110-
private async create() : Promise<IHistory> {
111-
const result = this.serviceContainer.get<IHistory>(IHistory);
112-
const handler = result.closed(this.onHistoryClosed);
113-
this.disposables.push(result);
115+
private async create() : Promise<void> {
116+
// Set it as soon as we create it. The .ctor for the history window
117+
// may cause a subclass to talk to the IHistoryProvider to get the active history.
118+
this.activeHistory = this.serviceContainer.get<IHistory>(IHistory);
119+
const handler = this.activeHistory.closed(this.onHistoryClosed);
120+
this.disposables.push(this.activeHistory);
114121
this.disposables.push(handler);
115-
this.activeHistoryExecuteHandler = result.onExecutedCode(this.onHistoryExecute);
122+
this.activeHistoryExecuteHandler = this.activeHistory.onExecutedCode(this.onHistoryExecute);
116123
this.disposables.push(this.activeHistoryExecuteHandler);
117-
await result.ready;
118-
return result;
124+
await this.activeHistory.ready;
119125
}
120126

121127
private onPeerCountChanged(newCount: number) {
@@ -133,7 +139,7 @@ export class HistoryProvider implements IHistoryProvider, IAsyncDisposable {
133139
// The other side is creating a history window. Create on this side. We don't need to show
134140
// it as the running of new code should do that.
135141
if (!this.activeHistory) {
136-
this.activeHistory = await this.create();
142+
await this.create();
137143
}
138144

139145
// Tell the requestor that we got its message (it should be waiting for all peers to sync)

src/test/datascience/liveshare.functional.test.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,14 @@ suite('LiveShare tests', () => {
144144
// The history provider create needs to be rewritten to make the history window think the mounted web panel is
145145
// ready.
146146
const origFunc = (historyProvider as any).create.bind(historyProvider);
147-
(historyProvider as any).create = async (): Promise<IHistory> => {
148-
const createResult = await origFunc();
147+
(historyProvider as any).create = async (): Promise<void> => {
148+
await origFunc();
149+
const history = historyProvider.getActive();
149150

150151
// During testing the MainPanel sends the init message before our history is created.
151152
// Pretend like it's happening now
152-
const listener = ((createResult as any)['messageListener']) as HistoryMessageListener;
153+
const listener = ((history as any).messageListener) as HistoryMessageListener;
153154
listener.onMessage(HistoryMessages.Started, {});
154-
155-
return createResult;
156155
};
157156

158157
return result;

0 commit comments

Comments
 (0)