Skip to content

Commit 3f6791e

Browse files
Merge pull request #293 from ethereum/vscode/theme
Fix vscode bug on deactivation
2 parents 61092ab + 9d6e37c commit 3f6791e

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

packages/engine/core/src/lib/abstract.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ export class Plugin<T extends Api = any, App extends ApiMap = any> implements Pl
108108
if (timedout) return
109109
resolve(result)
110110
} catch (err) {
111+
delete this.currentRequest
111112
reject(err)
112113
}
113114
clearTimeout(ref)

packages/engine/core/src/lib/manager.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,17 @@ export class PluginManager extends Plugin implements BasePluginManager {
186186
if (from.name === 'manager') {
187187
return this.toggleActive(name)
188188
}
189+
// Check manager rules
189190
const managerCanDeactivate = await this.canDeactivatePlugin(from, to)
190-
const pluginCanDeactivate = await this.call(to.name, 'canDeactivate', from)
191-
if (managerCanDeactivate && pluginCanDeactivate) {
192-
return this.toggleActive(name)
193-
} else {
191+
if (!managerCanDeactivate) {
192+
throw new Error(`Plugin ${this.requestFrom} has no right to deactivate plugin ${name}`)
193+
}
194+
// Ask plugin, if it wasn't the one which called on the first place
195+
const pluginCanDeactivate = from.name !== to.name ? await this.call(to.name, 'canDeactivate', from) : true
196+
if (!pluginCanDeactivate) {
194197
throw new Error(`Plugin ${this.requestFrom} has no right to deactivate plugin ${name}`)
195198
}
199+
return this.toggleActive(name)
196200
}
197201
return Array.isArray(names) ? catchAllPromises(names.map(deactivate)) : deactivate(names)
198202
}

packages/engine/vscode/src/lib/webview.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ export class WebviewPlugin extends PluginConnector {
2929
}
3030

3131
protected send(message: Partial<Message>): void {
32-
if (this.panel) {
33-
this.panel.webview.postMessage(message)
34-
}
32+
this.panel?.webview.postMessage(message)
3533
}
3634

3735
protected connect(url: string): void {

0 commit comments

Comments
 (0)