Skip to content

Commit 6f1ece0

Browse files
committed
more debug
1 parent e4404aa commit 6f1ece0

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

‎src/client/common/utils.ts‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,11 @@ export function execPythonFile(file: string, args: string[], cwd: string, includ
138138
});
139139
}
140140

141-
function handleResponse(file: string, includeErrorAsResponse: boolean, error: Error, stdout: string, stderr: string): Promise<string> {
141+
function handleResponse(file: string, includeErrorAsResponse: boolean, error: Error, stdout: string, stderr: string, token?: CancellationToken): Promise<string> {
142142
return new Promise<string>((resolve, reject) => {
143+
if (token.isCancellationRequested) {
144+
return;
145+
}
143146
if (isNotInstalledError(error)) {
144147
return reject(error);
145148
}
@@ -170,7 +173,7 @@ function handleResponse(file: string, includeErrorAsResponse: boolean, error: Er
170173
function execFileInternal(file: string, args: string[], options: child_process.ExecFileOptions, includeErrorAsResponse: boolean, token?: CancellationToken): Promise<string> {
171174
return new Promise<string>((resolve, reject) => {
172175
let proc = child_process.execFile(file, args, options, (error, stdout, stderr) => {
173-
handleResponse(file, includeErrorAsResponse, error, stdout, stderr).then(resolve, reject);
176+
handleResponse(file, includeErrorAsResponse, error, stdout, stderr, token).then(resolve, reject);
174177
});
175178
if (token && token.onCancellationRequested) {
176179
token.onCancellationRequested(() => {
@@ -310,17 +313,17 @@ export function getCustomEnvVars(): any {
310313
return null;
311314
}
312315

313-
export function getWindowsLineEndingCount(document:TextDocument, offset:Number) {
316+
export function getWindowsLineEndingCount(document: TextDocument, offset: Number) {
314317
const eolPattern = new RegExp('\r\n', 'g');
315318
const readBlock = 1024;
316319
let count = 0;
317320
let offsetDiff = offset.valueOf();
318321

319322
// In order to prevent the one-time loading of large files from taking up too much memory
320-
for (let pos = 0; pos < offset; pos += readBlock) {
323+
for (let pos = 0; pos < offset; pos += readBlock) {
321324
let startAt = document.positionAt(pos)
322325
let endAt = null;
323-
326+
324327
if (offsetDiff >= readBlock) {
325328
endAt = document.positionAt(pos + readBlock);
326329
offsetDiff = offsetDiff - readBlock;
@@ -330,7 +333,7 @@ export function getWindowsLineEndingCount(document:TextDocument, offset:Number)
330333

331334
let text = document.getText(new Range(startAt, endAt));
332335
let cr = text.match(eolPattern);
333-
336+
334337
count += cr ? cr.length : 0;
335338
}
336339
return count;

0 commit comments

Comments
 (0)