MCPcopy Index your code
hub / github.com/REditorSupport/vscode-R / showBrowser

Function showBrowser

src/session.ts:225–272  ·  view source on GitHub ↗
(url: string, title: string, viewer: string | boolean)

Source from the content-addressed store, hash-verified

223}
224
225export async function showBrowser(url: string, title: string, viewer: string | boolean): Promise<void> {
226 console.info(`[showBrowser] uri: ${url}, viewer: ${viewer.toString()}`);
227 const uri = Uri.parse(url);
228 if (viewer === false) {
229 void env.openExternal(uri);
230 } else {
231 const externalUri = await env.asExternalUri(uri);
232 const panel = window.createWebviewPanel(
233 'browser',
234 title,
235 {
236 preserveFocus: true,
237 viewColumn: ViewColumn[String(viewer) as keyof typeof ViewColumn],
238 },
239 {
240 enableFindWidget: true,
241 enableScripts: true,
242 retainContextWhenHidden: true,
243 });
244 if (isHost()) {
245 await shareBrowser(url, title);
246 }
247 panel.onDidChangeViewState((e: WebviewPanelOnDidChangeViewStateEvent) => {
248 if (e.webviewPanel.active) {
249 activeBrowserPanel = panel;
250 activeBrowserUri = uri;
251 activeBrowserExternalUri = externalUri;
252 } else {
253 activeBrowserPanel = undefined;
254 activeBrowserUri = undefined;
255 activeBrowserExternalUri = undefined;
256 }
257 void commands.executeCommand('setContext', 'r.browser.active', e.webviewPanel.active);
258 });
259 panel.onDidDispose(() => {
260 activeBrowserPanel = undefined;
261 activeBrowserUri = undefined;
262 activeBrowserExternalUri = undefined;
263 if (isHost()) {
264 closeBrowser(url);
265 }
266 void commands.executeCommand('setContext', 'r.browser.active', false);
267 });
268 panel.iconPath = new UriIcon('globe');
269 panel.webview.html = getBrowserHtml(externalUri);
270 }
271 console.info('[showBrowser] Done');
272}
273
274function getBrowserHtml(uri: Uri): string {
275 return `

Callers 2

updateGuestRequestFunction · 0.90
updateRequestFunction · 0.85

Calls 5

isHostFunction · 0.90
shareBrowserFunction · 0.90
closeBrowserFunction · 0.90
getBrowserHtmlFunction · 0.85
openExternalMethod · 0.80

Tested by

no test coverage detected