Skip to content

Commit 337607d

Browse files
committed
Make view result optional
In case it's not managed by a comm
1 parent 80ace2f commit 337607d

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

positron/comms/variables-backend-openrpc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@
186186
"schema": {
187187
"description": "The ID of the viewer that was opened.",
188188
"type": "string"
189-
}
189+
},
190+
"required": false
190191
}
191192
}
192193
],

src/vs/workbench/contrib/positronVariables/browser/components/variableItem.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,10 @@ export const VariableItem = (props: VariableItemProps) => {
138138
}
139139

140140
// If a binding was returned, save the binding between the viewer and the
141-
// variable item. Note that we intentionally treat `""` as falsy here so
142-
// that backends can return an empty ID if no comm was open. This happens
143-
// with Ark when the user views a function object: a virtual document is
144-
// opened in an editor but is not managed by a comm.
141+
// variable item. Note that it's valid for backends to not return any ID
142+
// if no comm was open. This happens with Ark when the user views a
143+
// function object: a virtual document is opened in an editor but is not
144+
// managed by a comm.
145145
if (viewerId) {
146146
explorerService.setInstanceForVar(viewerId, item.id);
147147
}

src/vs/workbench/services/languageRuntime/common/languageRuntimeVariablesClient.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ export class PositronVariable {
7676
/**
7777
* Requests that the language runtime open a viewer for this variable.
7878
*
79-
* @returns The ID of the viewer that was opened.
79+
* @returns The ID of the viewer that was opened, if any.
8080
*/
81-
async view(): Promise<string> {
81+
async view(): Promise<string | undefined> {
8282
const path = this.parentKeys.concat(this.data.access_key);
8383
return this._comm.view(path);
8484
}
@@ -268,4 +268,3 @@ export class VariablesClientInstance extends Disposable {
268268
}));
269269
}
270270
}
271-

src/vs/workbench/services/languageRuntime/common/positronVariablesComm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ export class PositronVariablesComm extends PositronBaseComm {
415415
*
416416
* @returns The ID of the viewer that was opened.
417417
*/
418-
view(path: Array<string>): Promise<string> {
418+
view(path: Array<string>): Promise<string | undefined> {
419419
return super.performRpc('view', ['path'], [path]);
420420
}
421421

src/vs/workbench/services/positronVariables/common/classes/variableItem.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ export class VariableItem implements IVariableItem {
324324
/**
325325
* Requests that a viewer be opened for this variable.
326326
*/
327-
async view(): Promise<string> {
327+
async view(): Promise<string | undefined> {
328328
return this._variable.view();
329329
}
330330

src/vs/workbench/services/positronVariables/common/interfaces/variableItem.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,5 @@ export interface IVariableItem {
8585
/**
8686
* Requests that a data viewer be opened for this variable.
8787
*/
88-
view(): Promise<string>;
88+
view(): Promise<string | undefined>;
8989
}

0 commit comments

Comments
 (0)