Skip to content

Commit

Permalink
force single instance
Browse files Browse the repository at this point in the history
  • Loading branch information
phil294 committed May 14, 2023
1 parent a7167ed commit 9d09389
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/extension.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,27 @@ git = (###* @type string ### args) =>
last_git_execution = Date.now()
stdout

``###* @type {vscode.Webview | null} ###
view = null
``###* @type {vscode.WebviewPanel | null} ###
panel = null

post_message = (###* @type BridgeMessage ### msg) =>
view?.postMessage msg
panel?.webview.postMessage msg

module.exports.activate = (###* @type vscode.ExtensionContext ### context) =>
context.subscriptions.push vscode.workspace.registerTextDocumentContentProvider "#{EXT_ID}-git-show",
provideTextDocumentContent: (uri) ->
(try await git "show \"#{uri.path}\"") or ''

context.subscriptions.push vscode.commands.registerCommand START_CMD, =>
if panel
panel.reveal()
return

panel = vscode.window.createWebviewPanel(EXT_NAME, EXT_NAME, vscode.window.activeTextEditor?.viewColumn or 1, { enableScripts: true, retainContextWhenHidden: true, localResourceRoots: [ vscode.Uri.joinPath(context.extensionUri, 'web-dist') ] })
panel.iconPath = vscode.Uri.joinPath(context.extensionUri, "logo.png")
view = panel.webview
panel.onDidDispose =>
panel = null

await refresh_folders()
selected_folder_path = context.workspaceState.get('selected_folder_path') or ''
Expand Down Expand Up @@ -139,7 +145,7 @@ module.exports.activate = (###* @type vscode.ExtensionContext ### context) =>
(if is_production then '' else '*') + '; '
get_web_uri = (###* @type {string[]} ### ...path_segments) =>
if is_production
view?.asWebviewUri vscode.Uri.joinPath context.extensionUri, 'web-dist', ...path_segments
view.asWebviewUri vscode.Uri.joinPath context.extensionUri, 'web-dist', ...path_segments
else
[dev_server_url, ...path_segments].join('/')
view.html = "
Expand Down

0 comments on commit 9d09389

Please sign in to comment.