Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit ccee9a9

Browse files
committed
last active file
1 parent 02a5f69 commit ccee9a9

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

main.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import { exec } from 'child_process';
77
interface PythonScripterSettings {
88
pythonPath: string;
99
pythonExe: string;
10-
useLastFile: boolean;
10+
// useLastFile: boolean;
1111
}
1212

1313
const DEFAULT_SETTINGS: PythonScripterSettings = {
1414
pythonPath: "",
1515
pythonExe: "",
16-
useLastFile: false
16+
// useLastFile: false
1717
}
1818

1919
export default class PythonScripterPlugin extends Plugin {
@@ -72,13 +72,19 @@ export default class PythonScripterPlugin extends Plugin {
7272
python_exe = this.settings.pythonExe
7373
}
7474
if (stats.isFile()) {
75-
var local_current_file_path = this.app.workspace.activeEditor?.file?.path;
76-
if (this.settings.useLastFile) {
77-
local_current_file_path = this.app.workspace.lastActiveFile?.path;
78-
}
75+
// var local_current_file_path = this.app.workspace.activeEditor?.file?.path;
76+
var local_current_file_path = this.app.workspace.getActiveFile()?.name?.toString();
7977
if (local_current_file_path === undefined) {
78+
// local_current_file_path = "";
8079
local_current_file_path = "";
8180
}
81+
// if (this.settings.useLastFile) {
82+
// local_current_file_path = this.app.workspace.getActiveFile()?.name?.toString();
83+
// }
84+
// else {
85+
// local_current_file_path = this.app.workspace.activeEditor?.file?.path;
86+
// }
87+
8288

8389

8490
exec(`${python_exe} \"${filePath}\" \"${basePath}\" \"${local_current_file_path}\"`, {cwd: this.pythonDirectory}, (error: any, stdout: any, stderr: any) => {
@@ -162,14 +168,14 @@ class PythonScripterSettingTab extends PluginSettingTab {
162168
this.plugin.settings.pythonExe = value;
163169
await this.plugin.saveSettings();
164170
}));
165-
new Setting(containerEl)
166-
.setName('Use Last File')
167-
.setDesc('Run the script on the last file that was opened. This make it possible to run it on other file types e.g. pdf.')
168-
.addToggle(toggle => toggle
169-
.setValue(this.plugin.settings.useLastFile)
170-
.onChange(async (value) => {
171-
this.plugin.settings.useLastFile = value;
172-
await this.plugin.saveSettings();
173-
}));
171+
// new Setting(containerEl)
172+
// .setName('Use Last File')
173+
// .setDesc('Run the script on the last file that was opened. This make it possible to run it on other file types e.g. pdf.')
174+
// .addToggle(toggle => toggle
175+
// .setValue(this.plugin.settings.useLastFile)
176+
// .onChange(async (value) => {
177+
// this.plugin.settings.useLastFile = value;
178+
// await this.plugin.saveSettings();
179+
// }));
174180
}
175181
}

0 commit comments

Comments
 (0)