MCPcopy Index your code
hub / github.com/microsoft/SandDance / viewInSandDance

Function viewInSandDance

extensions/azdata-sanddance/src/extension.ts:92–133  ·  view source on GitHub ↗
(rawTextPromise: () => Thenable<string>, uriFsPath: string, type: string, context: vscode.ExtensionContext, uriTabName?: string | undefined)

Source from the content-addressed store, hash-verified

90}
91
92function 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
135function viewFileUriInSandDance(fileUri: vscode.Uri, context: vscode.ExtensionContext, uriTabName?: string | undefined): void {
136 const p = () => new Promise<string>(resolve => {

Callers 3

onQueryEventFunction · 0.85
viewFileUriInSandDanceFunction · 0.85

Calls 4

newPanelFunction · 0.90
postMessageMethod · 0.65
getMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected