Skip to content

Commit d35c672

Browse files
authored
Ensure default browser is launched on Windows for survey/information popups. [ALTERNATE] (microsoft#2359)
- Use opn to launch browsers for surveys/information.
1 parent c3a04cd commit d35c672

2 files changed

Lines changed: 8 additions & 16 deletions

File tree

news/2 Fixes/2252.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix issue with survey not opening in a browser for Windows users.

src/client/common/net/browser.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,21 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
import * as child_process from 'child_process';
4+
'use strict';
5+
6+
// tslint:disable:no-require-imports no-var-requires
7+
const opn = require('opn');
8+
59
import { injectable } from 'inversify';
6-
import * as os from 'os';
710
import { IBrowserService } from '../types';
811

912
export function launch(url: string) {
10-
let openCommand: string | undefined;
11-
if (os.platform() === 'win32') {
12-
openCommand = 'explorer';
13-
} else if (os.platform() === 'darwin') {
14-
openCommand = '/usr/bin/open';
15-
} else {
16-
openCommand = '/usr/bin/xdg-open';
17-
}
18-
if (!openCommand) {
19-
console.error(`Unable to determine platform to launch the browser in the Python extension on platform '${os.platform()}'.`);
20-
console.error(`Link is: ${url}`);
21-
}
22-
child_process.spawn(openCommand, [url]);
13+
opn(url);
2314
}
2415

2516
@injectable()
2617
export class BrowserService implements IBrowserService {
27-
public launch(url: string): void{
18+
public launch(url: string): void {
2819
launch(url);
2920
}
3021
}

0 commit comments

Comments
 (0)