Skip to content

Commit 62ce2a9

Browse files
committed
fix bug related to large outputs
1 parent 53cd77b commit 62ce2a9

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "build-and-run",
33
"displayName": "Build and Run",
44
"description": "Build and Run your code with ease. Pass input from source comments.",
5-
"version": "1.0.2",
5+
"version": "1.0.3",
66
"publisher": "glelesius",
77
"bugs": {
88
"url": "https://github.com/gediminasel/build-and-run-vs/issues",

src/commands.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ function getOptionsWithDefaults(o?: OutputProgressOptions) {
8080
};
8181
}
8282

83-
class BuildAndRunException extends Error { }
84-
8583
export function listenCommandWithOutputAndProgress(command: CommandToSpawn, options?: OutputProgressOptions, input?: string): Thenable<void> {
8684
const settings = vscode.workspace.getConfiguration(SETTINGS_NAME);
8785
const outputFlushPeriod = settings.get("outputFlushPeriod", 500) as number;
@@ -91,8 +89,7 @@ export function listenCommandWithOutputAndProgress(command: CommandToSpawn, opti
9189
const opt = getOptionsWithDefaults(options);
9290

9391
const output = getOutputChannel();
94-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
95-
let outputBuffer: any[] = [];
92+
let outputBuffer: Uint8Array[][] = [];
9693
let outputText = "";
9794
let outputFile: WriteStream | null = null;
9895
let hadIllegalChars = false;
@@ -106,7 +103,7 @@ export function listenCommandWithOutputAndProgress(command: CommandToSpawn, opti
106103
}
107104
bufferString = bufferString.replaceAll('\0', "\\0");
108105

109-
if (outputText.length + bufferString.length <= MAX_OUTPUT_VIEW_SIZE) {
106+
if (outputFile === null && outputText.length + bufferString.length <= MAX_OUTPUT_VIEW_SIZE) {
110107
output.append(bufferString);
111108
outputText += bufferString;
112109
} else {
@@ -124,7 +121,9 @@ export function listenCommandWithOutputAndProgress(command: CommandToSpawn, opti
124121
output.append("\nFULL OUTPUT IN file:///" + outputFilePath);
125122
}
126123
}
127-
outputFile.write(bufferString);
124+
for (const chunk of outputBuffer) {
125+
outputFile.write(chunk);
126+
}
128127
}
129128
outputBuffer = [];
130129
};
@@ -133,7 +132,7 @@ export function listenCommandWithOutputAndProgress(command: CommandToSpawn, opti
133132
location: vscode.ProgressLocation.Window,
134133
cancellable: true
135134
}, (progress, token) => {
136-
return new Promise((resolve, reject) => {
135+
return new Promise((resolve) => {
137136
token.onCancellationRequested(() => {
138137
if (child)
139138
killCommand(child);
@@ -163,7 +162,7 @@ export function listenCommandWithOutputAndProgress(command: CommandToSpawn, opti
163162
if (code || signal) {
164163
const exitCode = (code ? code : signal);
165164
output.append(opt.failureMsg(endTime - startTime, exitCode));
166-
reject(new BuildAndRunException());
165+
resolve();
167166
} else {
168167
output.append(opt.successMsg(endTime - startTime));
169168
resolve();
@@ -174,8 +173,7 @@ export function listenCommandWithOutputAndProgress(command: CommandToSpawn, opti
174173
}
175174
}, input);
176175

177-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
178-
const outHandler = (data: any) => {
176+
const outHandler = (data: Uint8Array[]) => {
179177
outputBuffer.push(data);
180178
};
181179

0 commit comments

Comments
 (0)