franciscorubin/vscode-ipython

Feature request: ipython.runFileInIPython

Opened this issue · 1 comments

Hi,

First of all, thank you for sharing the extension. I have started with Jupyter which I found slow compared to naive ipython, so I move to iPython. With your extension, the workflow is about the same.

One request I would like to make is a new feature "ipython.runFileInIPython". Currently, when I want to run a script, I execute

ipython.sendFileContentsToIPython

. Yes, it does the job, but it fills the entire ipython screen with a long list of lines. For the purpose of analysis, it would be helpful if it simply runs "run file" or something similar with the requested feature.

EDIT:
With my limited knowledge, I had a look at the sourcecode. In extension.js line 66, if we replace the line to
const command = run ${filename};
I suspect that it might do the job with a new function definition.

Thank you.

Regards,
Chanyeol

I added the following and it does what I wanted. If it could be added in the next update, I would greatly appreciate (if you find it useful) since I use your extension in all my workstations

    let runFileInIPython = vscode.commands.registerCommand('ipython.runFileInIPython', function () {
        if (pythonTerminal === null) {
            createPythonTerminal();
        }

        const editor = vscode.window.activeTextEditor;
        const filename = editor.document.fileName;
        if (filename !== currentFilename) {
            updateFilename(filename);
        }

        sendQueuedText(`run ${filename}`, 100);
        sendQueuedText('\n\n');
        pythonTerminal.show();
    });

    context.subscriptions.push(runFileInIPython);