Skip to content

Commit 53e3594

Browse files
feat(overmind-devtools-vscode): open in focused window and reopen on restart
1 parent 9435252 commit 53e3594

File tree

4 files changed

+37
-145
lines changed

4 files changed

+37
-145
lines changed

packages/node_modules/overmind-devtools-vscode/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Overmind Devtools VSCode",
44
"description": "Devtools for Overmind",
55
"publisher": "christianalfoni",
6-
"version": "0.0.13",
6+
"version": "0.0.14",
77
"repository": {
88
"type": "git",
99
"url": "https://github.com/cerebral/overmind.git"

packages/node_modules/overmind-devtools-vscode/src/DevtoolsPanel.ts

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,33 @@ export class DevtoolsPanel {
1818
constructor(options: Options) {
1919
this._options = options
2020
}
21-
show(content: string) {
21+
show(content: string, panel?: vscode.WebviewPanel) {
2222
if (this._panel) {
2323
this._panel.dispose()
2424
}
2525

26-
this._panel = vscode.window.createWebviewPanel(
27-
DevtoolsPanel.viewType,
28-
'Overmind',
29-
this.getColumn(),
30-
{
31-
enableScripts: true,
32-
retainContextWhenHidden: true,
33-
localResourceRoots: [
34-
vscode.Uri.file(
35-
path.join(this._options.context.extensionPath, 'devtoolsDist')
36-
),
37-
],
38-
}
39-
)
26+
this._panel =
27+
panel ||
28+
vscode.window.createWebviewPanel(
29+
DevtoolsPanel.viewType,
30+
'Overmind',
31+
{
32+
viewColumn:
33+
vscode.window.activeTextEditor &&
34+
vscode.window.activeTextEditor.viewColumn
35+
? vscode.window.activeTextEditor.viewColumn
36+
: vscode.ViewColumn.One,
37+
},
38+
{
39+
enableScripts: true,
40+
retainContextWhenHidden: true,
41+
localResourceRoots: [
42+
vscode.Uri.file(
43+
path.join(this._options.context.extensionPath, 'devtoolsDist')
44+
),
45+
],
46+
}
47+
)
4048

4149
this._panel.webview.onDidReceiveMessage(
4250
(message) => {
@@ -55,17 +63,6 @@ export class DevtoolsPanel {
5563
this._options.context.subscriptions
5664
)
5765
this._panel.webview.html = content
58-
this._panel.reveal(this.getColumn())
59-
}
60-
61-
private getColumn() {
62-
if (
63-
vscode.window.activeTextEditor &&
64-
vscode.window.activeTextEditor.viewColumn
65-
) {
66-
return vscode.window.activeTextEditor.viewColumn
67-
}
68-
69-
return vscode.ViewColumn.One
66+
this._panel.reveal()
7067
}
7168
}

packages/node_modules/overmind-devtools-vscode/src/DevtoolsPanel_old.ts

Lines changed: 0 additions & 92 deletions
This file was deleted.

packages/node_modules/overmind-devtools-vscode/src/extension.ts

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function activate(context: vscode.ExtensionContext) {
5454
},
5555
})
5656

57-
function startDevtools() {
57+
function startDevtools(panel?: vscode.WebviewPanel) {
5858
const port: number =
5959
vscode.workspace.getConfiguration().get('overmind.port') || 3031
6060

@@ -64,27 +64,20 @@ export function activate(context: vscode.ExtensionContext) {
6464
let scriptFile: vscode.Uri | string
6565

6666
// TODO consider https://github.com/microsoft/vscode/commit/fbcdb4c6a736ff38e60a7e9d0a3f1be5ccbaf3af ?
67-
if (process.env.VSCODE_DEBUG_MODE || vscode.workspace.getConfiguration().get('overmind.devmode.enabled')) {
68-
scriptFile = <string>vscode.workspace.getConfiguration().get('overmind.devmode.url')
67+
if (
68+
process.env.VSCODE_DEBUG_MODE ||
69+
vscode.workspace.getConfiguration().get('overmind.devmode.enabled')
70+
) {
71+
scriptFile = <string>(
72+
vscode.workspace.getConfiguration().get('overmind.devmode.url')
73+
)
6974
} else {
7075
const onDiskPath = vscode.Uri.file(
7176
path.join(context.extensionPath, 'devtoolsDist', 'bundle.js')
7277
)
7378
scriptFile = onDiskPath.with({ scheme: 'vscode-resource' })
7479
}
7580

76-
/*
77-
// activityBar-background
78-
foreground: 'hsl(206, 57%, 17%)',
79-
// editor-background
80-
background: 'hsl(206, 57%, 13%)',
81-
// dropdown-border
82-
border: 'hsl(206, 57%, 16%)',
83-
// editor-foreground
84-
text: 'hsl(0, 0%, 90%)',
85-
// focusForeground
86-
highlight: 'hsl(0, 0%, 85%)'
87-
*/
8881
devtoolsPanel.show(
8982
devtoolBackend.getMarkup(scriptFile, port).replace(
9083
'</head>',
@@ -126,7 +119,8 @@ export function activate(context: vscode.ExtensionContext) {
126119
command: 'restart',
127120
})
128121
}
129-
)
122+
),
123+
panel
130124
)
131125
})
132126
}
@@ -135,20 +129,13 @@ export function activate(context: vscode.ExtensionContext) {
135129
vscode.commands.registerCommand('overmind-devtools.start', startDevtools)
136130
)
137131

138-
// This is supposed keep Overmind extension in same position on restart, though
139-
// do not think we need that really? https://code.visualstudio.com/api/extension-guides/webview
140-
/*
141132
if (vscode.window.registerWebviewPanelSerializer) {
142133
vscode.window.registerWebviewPanelSerializer(DevtoolsPanel.viewType, {
143-
async deserializeWebviewPanel(
144-
webViewPanel: vscode.WebviewPanel,
145-
state: any
146-
) {
147-
DevtoolsPanel.revive(webViewPanel, context.extensionPath)
134+
async deserializeWebviewPanel(webViewPanel: vscode.WebviewPanel) {
135+
startDevtools(webViewPanel)
148136
},
149137
})
150138
}
151-
*/
152139
}
153140

154141
// this method is called when your extension is deactivated

0 commit comments

Comments
 (0)