<commit_before>"use strict";
import * as vscode from "vscode";
import * as settings from "./../common/configSettings";

export function activateExecInTerminalProvider() {
    vscode.commands.registerCommand("python.execInTerminal", execInTerminal);
}

function execInTerminal(fileUri?: vscode.Uri) {
    const currentPythonPath = settings.PythonSettings.getInstance().pythonPath;
    let filePath: string;

    if (fileUri === undefined) {
        const activeEditor = vscode.window.activeTextEditor;
        if (activeEditor !== undefined) {
            if (!activeEditor.document.isUntitled) {
                filePath = activeEditor.document.fileName;
            } else {
                vscode.window.showErrorMessage('The active file needs to be saved before it can be run');
                return;
            }
        } else {
            vscode.window.showErrorMessage('No open file to run in terminal');
            return;
        }
    } else {
        filePath = fileUri.fsPath;
    }

    const terminal = (<any>vscode.window).createTerminal(`Python`);
    // Temporary workaround until a promise of terminal readiness is available:
    // https://github.com/Tyriar/vscode-terminal-api-example/issues/2
    setTimeout(() => {
        terminal.sendText(`${currentPythonPath} ${filePath}`);
    }, 1000);<commit_msg>only allow command on python files<commit_after>"use strict";
import * as vscode from "vscode";
import * as settings from "./../common/configSettings";

export function activateExecInTerminalProvider() {
    vscode.commands.registerCommand("python.execInTerminal", execInTerminal);
}

function execInTerminal(fileUri?: vscode.Uri) {
    const currentPythonPath = settings.PythonSettings.getInstance().pythonPath;
    let filePath: string;

    if (fileUri === undefined) {
        const activeEditor = vscode.window.activeTextEditor;
        if (activeEditor !== undefined) {
            if (!activeEditor.document.isUntitled) {
                if (activeEditor.document.languageId == "python") {
                    filePath = activeEditor.document.fileName;
                } else {
                    vscode.window.showErrorMessage('The active file is not a Python source file');
                    return;
                }
            } else {
                vscode.window.showErrorMessage('The active file needs to be saved before it can be run');
                return;
            }
        } else {
            vscode.window.showErrorMessage('No open file to run in terminal');
            return;
        }
    } else {
        filePath = fileUri.fsPath;
    }

    const terminal = (<any>vscode.window).createTerminal(`Python`);
    // Temporary workaround until a promise of terminal readiness is available:
    // https://github.com/Tyriar/vscode-terminal-api-example/issues/2
    setTimeout(() => {
        terminal.sendText(`${currentPythonPath} ${filePath}`);
    }, 1000);
{'fraction_non_alphanumeric': 0.1108450222374273, 'fraction_numerical': 0.0034211426616489907, 'mean_word_length': 2.510204081632653, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '245547', 'n_tokens_mistral': 809, 'n_tokens_neox': 777, 'n_words': 184}