Skip to content

Commit 63abb75

Browse files
authored
Merge pull request microsoft#162072 from microsoft/tyriar/161775
Fix free port quick fix on Windows
2 parents 5c35efe + e77c6d8 commit 63abb75

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/vs/platform/terminal/node/ptyService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export class PtyService extends Disposable implements IPtyService {
124124
await new Promise<string>((resolve, reject) => {
125125
exec(`kill ${processId}`, {}, (err, stdout) => {
126126
if (err) {
127-
return reject(`Problem occurred when killing the process w ID: ${processId}`);
127+
return reject(`Problem occurred when killing the process with PID: ${processId}`);
128128
}
129129
resolve(stdout);
130130
});
@@ -143,13 +143,13 @@ export class PtyService extends Disposable implements IPtyService {
143143
});
144144
const processesForPort = stdout.split('\n');
145145
if (processesForPort.length >= 1) {
146-
const capturePid = /LISTENING\s+(\d{3})/;
146+
const capturePid = /LISTENING\s+(\d+)/;
147147
const processId = processesForPort[0].match(capturePid)?.[1];
148148
if (processId) {
149149
await new Promise<string>((resolve, reject) => {
150150
exec(`Taskkill /F /PID ${processId}`, {}, (err, stdout) => {
151151
if (err) {
152-
return reject(`Problem occurred when killing the process w ID: ${processId}`);
152+
return reject(`Problem occurred when killing the process with PID: ${processId}`);
153153
}
154154
resolve(stdout);
155155
});

src/vs/workbench/contrib/terminal/browser/terminalQuickFixBuiltinActions.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { IAction } from 'vs/base/common/actions';
7-
import { isWindows } from 'vs/base/common/platform';
87
import { localize } from 'vs/nls';
98
import { IOpenerService } from 'vs/platform/opener/common/opener';
109
import { QuickFixMatchResult, ITerminalQuickFixAction, ITerminalQuickFixOptions, ITerminalInstance } from 'vs/workbench/contrib/terminal/browser/terminal';
@@ -14,7 +13,7 @@ export const GitCommandLineRegex = /git/;
1413
export const GitPushCommandLineRegex = /git\s+push/;
1514
export const AnyCommandLineRegex = /.+/;
1615
export const GitSimilarOutputRegex = /most similar command is\s*([^\s]{3,})/;
17-
export const FreePortOutputRegex = /address already in use \d\.\d\.\d\.\d:(\d\d\d\d)|Unable to bind [^ ]*:(\d+)|can't listen on port (\d+)|listen EADDRINUSE [^ ]*:(\d+)/;
16+
export const FreePortOutputRegex = /address already in use \d+\.\d+\.\d+\.\d+:(\d{4,5})|Unable to bind [^ ]*:(\d{4,5})|can't listen on port (\d{4,5})|listen EADDRINUSE [^ ]*:(\d{4,5})/;
1817
export const GitPushOutputRegex = /git push --set-upstream origin ([^\s]+)/;
1918
export const GitCreatePrOutputRegex = /Create a pull request for \'([^\s]+)\' on GitHub by visiting:\s*remote:\s*(https:.+pull.+)/;
2019

@@ -50,8 +49,7 @@ export function freePort(terminalInstance?: Partial<ITerminalInstance>): ITermin
5049
return {
5150
quickFixLabel: (matchResult: QuickFixMatchResult) => matchResult.outputMatch ? `Free port ${matchResult.outputMatch[1]}` : '',
5251
commandLineMatcher: AnyCommandLineRegex,
53-
// TODO: Support free port on Windows https://github.com/microsoft/vscode/issues/161775
54-
outputMatcher: isWindows ? undefined : {
52+
outputMatcher: {
5553
lineMatcher: FreePortOutputRegex,
5654
anchor: 'bottom',
5755
offset: 0,

0 commit comments

Comments
 (0)