(rawTextPromise: () => Thenable<string>, uriFsPath: string, type: string, context: vscode.ExtensionContext, uriTabName?: string | undefined)
| 90 | } |
| 91 | |
| 92 | function viewInSandDance(rawTextPromise: () => Thenable<string>, uriFsPath: string, type: string, context: vscode.ExtensionContext, uriTabName?: string | undefined): void { |
| 93 | const columnToShowIn = vscode.window.activeTextEditor ? vscode.window.activeTextEditor.viewColumn : undefined; |
| 94 | //only allow one SandDance at a time |
| 95 | if (current && current.uriFsPath !== uriFsPath) { |
| 96 | current.panel.dispose(); |
| 97 | current = undefined; |
| 98 | } |
| 99 | if (current) { |
| 100 | //TODO: registerWebviewPanelSerializer to hydrate state |
| 101 | // If we already have a panel, show it in the target column |
| 102 | current.panel.reveal(columnToShowIn); |
| 103 | } |
| 104 | else { |
| 105 | // Otherwise, create a new panel |
| 106 | current = newPanel(context, uriFsPath, uriTabName); |
| 107 | current.panel.onDidDispose(() => { |
| 108 | current = undefined; |
| 109 | }, null, context.subscriptions); |
| 110 | // Handle messages from the webview |
| 111 | current.panel.webview.onDidReceiveMessage(message => { |
| 112 | switch (message.command) { |
| 113 | case 'getFileContent': { |
| 114 | rawTextPromise().then(rawText => { |
| 115 | if (current && current.panel.visible) { |
| 116 | const dataFile = { |
| 117 | type, |
| 118 | rawText, |
| 119 | }; |
| 120 | const compactUI = context.globalState.get('compactUI'); |
| 121 | current.panel.webview.postMessage({ command: 'gotFileContent', dataFile, compactUI }); |
| 122 | } |
| 123 | }); |
| 124 | break; |
| 125 | } |
| 126 | case 'setCompactUI': { |
| 127 | context.globalState.update('compactUI', message.compactUI); |
| 128 | break; |
| 129 | } |
| 130 | } |
| 131 | }, undefined, context.subscriptions); |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | function viewFileUriInSandDance(fileUri: vscode.Uri, context: vscode.ExtensionContext, uriTabName?: string | undefined): void { |
| 136 | const p = () => new Promise<string>(resolve => { |
no test coverage detected