Skip to content

Commit 91bec70

Browse files
authored
Merge branch 'main' into dynamic-impala
2 parents c96e527 + ebc683a commit 91bec70

File tree

5 files changed

+40
-85
lines changed

5 files changed

+40
-85
lines changed

package-lock.json

Lines changed: 9 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1713,7 +1713,7 @@
17131713
"semver": "^7.5.2",
17141714
"stack-trace": "0.0.10",
17151715
"sudo-prompt": "^9.2.1",
1716-
"tmp": "^0.0.33",
1716+
"tmp": "^0.2.5",
17171717
"uint64be": "^3.0.0",
17181718
"unicode": "^14.0.0",
17191719
"vscode-debugprotocol": "^1.28.0",

src/client/common/platform/fs-temp.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,7 @@ import * as tmp from 'tmp';
55
import { ITempFileSystem, TemporaryFile } from './types';
66

77
interface IRawTempFS {
8-
// TODO (https://github.com/microsoft/vscode/issues/84517)
9-
// This functionality has been requested for the
10-
// VS Code FS API (vscode.workspace.fs.*).
11-
file(
12-
config: tmp.Options,
13-
14-
callback?: (err: any, path: string, fd: number, cleanupCallback: () => void) => void,
15-
): void;
8+
fileSync(config?: tmp.Options): tmp.SynchrounousResult;
169
}
1710

1811
// Operations related to temporary files and directories.
@@ -35,14 +28,13 @@ export class TemporaryFileSystem implements ITempFileSystem {
3528
mode,
3629
};
3730
return new Promise<TemporaryFile>((resolve, reject) => {
38-
this.raw.file(opts, (err, filename, _fd, cleanUp) => {
39-
if (err) {
40-
return reject(err);
41-
}
42-
resolve({
43-
filePath: filename,
44-
dispose: cleanUp,
45-
});
31+
const { name, removeCallback } = this.raw.fileSync(opts);
32+
if (!name) {
33+
return reject(new Error('Failed to create temp file'));
34+
}
35+
resolve({
36+
filePath: name,
37+
dispose: removeCallback,
4638
});
4739
});
4840
}

src/client/terminals/codeExecution/codeExecutionManager.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { inject, injectable } from 'inversify';
77
import { Disposable, EventEmitter, Terminal, Uri } from 'vscode';
8-
8+
import * as path from 'path';
99
import { ICommandManager, IDocumentManager } from '../../common/application/types';
1010
import { Commands } from '../../common/constants';
1111
import '../../common/extensions';
@@ -130,6 +130,15 @@ export class CodeExecutionManager implements ICodeExecutionManager {
130130
if (!fileToExecute) {
131131
return;
132132
}
133+
134+
// Check on setting terminal.executeInFileDir
135+
const pythonSettings = this.configSettings.getSettings(file);
136+
let cwd = pythonSettings.terminal.executeInFileDir ? path.dirname(fileToExecute.fsPath) : undefined;
137+
138+
// Check on setting terminal.launchArgs
139+
const launchArgs = pythonSettings.terminal.launchArgs;
140+
const totalArgs = [...launchArgs, fileToExecute.fsPath.fileToCommandArgumentForPythonExt()];
141+
133142
const fileAfterSave = await codeExecutionHelper.saveFileIfDirty(fileToExecute);
134143
if (fileAfterSave) {
135144
fileToExecute = fileAfterSave;
@@ -138,19 +147,9 @@ export class CodeExecutionManager implements ICodeExecutionManager {
138147
const show = this.shouldTerminalFocusOnStart(fileToExecute);
139148
let terminal: Terminal | undefined;
140149
if (dedicated) {
141-
terminal = await runInDedicatedTerminal(
142-
fileToExecute,
143-
[fileToExecute.fsPath.fileToCommandArgumentForPythonExt()],
144-
undefined,
145-
show,
146-
);
150+
terminal = await runInDedicatedTerminal(fileToExecute, totalArgs, cwd, show);
147151
} else {
148-
terminal = await runInTerminal(
149-
fileToExecute,
150-
[fileToExecute.fsPath.fileToCommandArgumentForPythonExt()],
151-
undefined,
152-
show,
153-
);
152+
terminal = await runInTerminal(fileToExecute, totalArgs, cwd, show);
154153
}
155154

156155
if (terminal) {

src/test/common/platform/fs-temp.unit.test.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ import { TemporaryFileSystem } from '../../../client/common/platform/fs-temp';
77

88
interface IDeps {
99
// tmp module
10-
file(
11-
config: { postfix?: string; mode?: number },
12-
13-
callback?: (err: any, path: string, fd: number, cleanupCallback: () => void) => void,
14-
): void;
10+
fileSync(config: {
11+
postfix?: string;
12+
mode?: number;
13+
}): {
14+
name: string;
15+
fd: number;
16+
removeCallback(): void;
17+
};
1518
}
1619

1720
suite('FileSystem - temp files', () => {
@@ -28,7 +31,7 @@ suite('FileSystem - temp files', () => {
2831
suite('createFile', () => {
2932
test(`fails if the raw call fails`, async () => {
3033
const failure = new Error('oops');
31-
deps.setup((d) => d.file({ postfix: '.tmp', mode: undefined }, TypeMoq.It.isAny()))
34+
deps.setup((d) => d.fileSync({ postfix: '.tmp', mode: undefined }))
3235
// fail with an arbitrary error
3336
.throws(failure);
3437

@@ -40,7 +43,7 @@ suite('FileSystem - temp files', () => {
4043

4144
test(`fails if the raw call "returns" an error`, async () => {
4245
const failure = new Error('oops');
43-
deps.setup((d) => d.file({ postfix: '.tmp', mode: undefined }, TypeMoq.It.isAny())).callback((_cfg, cb) =>
46+
deps.setup((d) => d.fileSync({ postfix: '.tmp', mode: undefined })).callback((_cfg, cb) =>
4447
cb(failure, '...', -1, () => {}),
4548
);
4649

0 commit comments

Comments
 (0)