дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-28 05:22:23 +02:00
Adds a Python Console tool window: an interactive interpreter of the project's Python (the one Settings and the status bar show; in a workspace, the member the active file is in), started in the project root with the source roots on `PYTHONPATH`. It uses IPython when the interpreter has it and plain Python otherwise, in its own `__main__`. Enter runs the input, Shift+Enter adds a line, Up/Down recall earlier inputs, and while code runs a typed line answers its `input()`. A Variables pane lists the console's globals after each run. Execute Selection in Python Console (`python.console.executeSelection`, Alt+Shift+E, also in the editor context menu of Python files) sends the selection or the current line, starting the console if needed; a selection inside an indented block is dedented. The console is a small driver script run on the existing Run process host, so there are no backend changes. Closes #5148 Co-authored-by: wildcatDownstairs <[email protected]>
21 рядки
960 B
TypeScript
21 рядки
960 B
TypeScript
import { EditorSelection, EditorState } from "@codemirror/state";
|
|
import { expect, it } from "vitest";
|
|
import { selectionCode } from "./selection";
|
|
|
|
const DOC = "def f():\n for i in range(2):\n print(i)\n print('done')\n";
|
|
const at = (from: number, to = from) =>
|
|
selectionCode(EditorState.create({ doc: DOC, selection: EditorSelection.single(from, to) }));
|
|
|
|
it("sends the caret's line when nothing is selected", () => {
|
|
expect(at(DOC.indexOf("print(i)"))).toBe(" print(i)");
|
|
});
|
|
|
|
it("gives a selection that starts after the indentation its indentation back", () => {
|
|
// Selected from `for` (as a double-click or Shift+Down from there selects) to the end.
|
|
expect(at(DOC.indexOf("for"), DOC.length)).toBe(" for i in range(2):\n print(i)\n print('done')\n");
|
|
});
|
|
|
|
it("leaves a selection that starts mid-statement as it is", () => {
|
|
expect(at(DOC.indexOf("range"), DOC.indexOf(":\n print"))).toBe("range(2)");
|
|
});
|