дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-22 01:20:46 +02:00
Порівняти коміти
3
Коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
6b3519c7f8 | ||
|
|
fdc8bc2d4c | ||
|
|
497d4766d7 |
No files matched your search
@@ -46,7 +46,7 @@ it("keeps mapped lenses across edits instead of clearing them (#2710)", async ()
|
|||||||
data: [
|
data: [
|
||||||
{
|
{
|
||||||
range: { start: { line: 1, col: 0 }, end: { line: 1, col: 3 } },
|
range: { start: { line: 1, col: 0 }, end: { line: 1, col: 3 } },
|
||||||
command: { title: "1 reference", command: "csharp.showReferences", arguments: [] },
|
command: { title: "Run test", command: "csharp.runTest", arguments: [] },
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
@@ -67,5 +67,27 @@ it("keeps mapped lenses across edits instead of clearing them (#2710)", async ()
|
|||||||
const after = view.state.facet(codeLenses);
|
const after = view.state.facet(codeLenses);
|
||||||
expect(after).toHaveLength(1);
|
expect(after).toHaveLength(1);
|
||||||
expect(after[0]!.pos).toBe(posBefore + 1);
|
expect(after[0]!.pos).toBe(posBefore + 1);
|
||||||
expect(after[0]!.title).toBe("1 reference");
|
expect(after[0]!.title).toBe("Run test");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("leaves reference counts to Code Vision's usages", async () => {
|
||||||
|
vi.useFakeTimers();
|
||||||
|
const lens = (line: number, title: string) => ({
|
||||||
|
range: { start: { line, col: 0 }, end: { line, col: 1 } },
|
||||||
|
command: { title, command: "csharp.showReferences", arguments: [] },
|
||||||
|
});
|
||||||
|
ipc.lspCodeLens.mockResolvedValue({
|
||||||
|
status: "ok",
|
||||||
|
data: [lens(0, "3 Reference(s)"), lens(1, "1 reference"), lens(2, "12 references"), lens(3, "2 implementations")],
|
||||||
|
});
|
||||||
|
const view = new EditorView({
|
||||||
|
state: EditorState.create({
|
||||||
|
doc: "a\nb\nc\nd",
|
||||||
|
extensions: serverCodeLenses({ doc: 1, path: "/p/a.cs", language: "csharp", uiMode: null, readOnly: false }),
|
||||||
|
}),
|
||||||
|
parent: document.body,
|
||||||
|
});
|
||||||
|
views.push(view);
|
||||||
|
await vi.advanceTimersByTimeAsync(400);
|
||||||
|
expect(view.state.facet(codeLenses).map((l) => l.title)).toEqual(["2 implementations"]);
|
||||||
});
|
});
|
||||||
@@ -6,6 +6,12 @@ import { call, commands } from "@/platform/ipc";
|
|||||||
import { onNavigationProvidersChanged } from "@/editor/navigationProviders";
|
import { onNavigationProvidersChanged } from "@/editor/navigationProviders";
|
||||||
import { posToOffset } from "./positions";
|
import { posToOffset } from "./positions";
|
||||||
import { onLspRefresh, onServerSettled } from "./availability";
|
import { onLspRefresh, onServerSettled } from "./availability";
|
||||||
|
/**
|
||||||
|
* A server's reference count ("3 references", csharp-ls's "3 Reference(s)"): Code Vision's
|
||||||
|
* Usages shows the same count above the declaration, under its own setting.
|
||||||
|
*/
|
||||||
|
const REFERENCE_COUNT = /^\s*\d+\s+references?(\(s\))?\s*$/i;
|
||||||
|
|
||||||
const set = StateEffect.define<CodeLens[]>();
|
const set = StateEffect.define<CodeLens[]>();
|
||||||
const field = StateField.define<CodeLens[]>({
|
const field = StateField.define<CodeLens[]>({
|
||||||
create: () => [],
|
create: () => [],
|
||||||
@@ -62,7 +68,7 @@ export function serverCodeLenses(ctx: EditorDocContext): Extension {
|
|||||||
view.dispatch({
|
view.dispatch({
|
||||||
effects: set.of(
|
effects: set.of(
|
||||||
result.flatMap((l) =>
|
result.flatMap((l) =>
|
||||||
l.command
|
l.command && !REFERENCE_COUNT.test(l.command.title)
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
pos: posToOffset(text, l.range.start),
|
pos: posToOffset(text, l.range.start),
|
||||||
|
|||||||
@@ -43,13 +43,23 @@ export function AddInterpreterDialog({
|
|||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
const ids = { base: useId(), location: useId(), existing: useId() };
|
const ids = { base: useId(), location: useId(), existing: useId() };
|
||||||
|
|
||||||
const baseValue = base ?? bases[0]?.path ?? null;
|
|
||||||
const toOption = (s: { path: string; name: string }): SelectOption => ({
|
const toOption = (s: { path: string; name: string }): SelectOption => ({
|
||||||
value: s.path,
|
value: s.path,
|
||||||
label: s.name,
|
label: s.name,
|
||||||
detail: tildify(s.path),
|
detail: tildify(s.path),
|
||||||
});
|
});
|
||||||
const baseOptions = bases.map(toOption);
|
// conda installs a fresh Python of the base's version: offer versions, not environments to copy.
|
||||||
|
const versionOptions = (() => {
|
||||||
|
const seen = new Map<string, SelectOption>();
|
||||||
|
for (const s of bases) {
|
||||||
|
const short = s.version?.split(".").slice(0, 2).join(".");
|
||||||
|
if (short && !seen.has(short)) seen.set(short, { value: s.path, label: tx`Python ${short}` });
|
||||||
|
}
|
||||||
|
return [...seen.values()].sort((a, b) => b.label.localeCompare(a.label, undefined, { numeric: true }));
|
||||||
|
})();
|
||||||
|
const baseOptions = kind === "conda" ? versionOptions : bases.map(toOption);
|
||||||
|
const baseValue =
|
||||||
|
base ?? (kind === "conda" ? (versionOptions[0]?.value as string | undefined) : bases[0]?.path) ?? null;
|
||||||
const existingOptions = [...browsed, ...list.filter((s) => !browsed.some((b) => b.path === s.path))].map((s) => ({
|
const existingOptions = [...browsed, ...list.filter((s) => !browsed.some((b) => b.path === s.path))].map((s) => ({
|
||||||
value: s.path,
|
value: s.path,
|
||||||
label: `${s.name} — ${tildify(s.path)}`,
|
label: `${s.name} — ${tildify(s.path)}`,
|
||||||
@@ -108,7 +118,9 @@ export function AddInterpreterDialog({
|
|||||||
const canOk = !busy && (mode === "new" ? !!baseValue && !!location.trim() : !!existing?.trim());
|
const canOk = !busy && (mode === "new" ? !!baseValue && !!location.trim() : !!existing?.trim());
|
||||||
const note = {
|
const note = {
|
||||||
venv: tx("Runs “<base> -m venv <location>”; the new interpreter becomes the project interpreter."),
|
venv: tx("Runs “<base> -m venv <location>”; the new interpreter becomes the project interpreter."),
|
||||||
conda: tx("Runs “conda create -p <location>”; the new interpreter becomes the project interpreter."),
|
conda: tx(
|
||||||
|
"Runs “conda create -p <location> python=<version>”: a new environment with only Python in it; the new interpreter becomes the project interpreter.",
|
||||||
|
),
|
||||||
uv: tx("Runs “uv venv <location> --python <base>”; the new interpreter becomes the project interpreter."),
|
uv: tx("Runs “uv venv <location> --python <base>”; the new interpreter becomes the project interpreter."),
|
||||||
poetry: tx(
|
poetry: tx(
|
||||||
"Runs “poetry env use <base>” in the project; poetry keeps the environment under its own cache directory.",
|
"Runs “poetry env use <base>” in the project; poetry keeps the environment under its own cache directory.",
|
||||||
@@ -143,6 +155,7 @@ export function AddInterpreterDialog({
|
|||||||
aria-current={kind === k.tool || undefined}
|
aria-current={kind === k.tool || undefined}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setKind(k.tool);
|
setKind(k.tool);
|
||||||
|
setBase(null);
|
||||||
setError(null);
|
setError(null);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -199,9 +212,7 @@ export function AddInterpreterDialog({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<label htmlFor={ids.base}>
|
<label htmlFor={ids.base}>{kind === "conda" ? <T>Python version:</T> : <T>Base interpreter:</T>}</label>
|
||||||
<T>Base interpreter:</T>
|
|
||||||
</label>
|
|
||||||
<div className={styles.pathRow}>
|
<div className={styles.pathRow}>
|
||||||
<Select
|
<Select
|
||||||
className={styles.pathInput}
|
className={styles.pathInput}
|
||||||
@@ -209,17 +220,19 @@ export function AddInterpreterDialog({
|
|||||||
options={baseOptions}
|
options={baseOptions}
|
||||||
onChange={setBase}
|
onChange={setBase}
|
||||||
placeholder={loading ? "Detecting…" : "No Python found"}
|
placeholder={loading ? "Detecting…" : "No Python found"}
|
||||||
aria-label="Base interpreter"
|
aria-label={kind === "conda" ? "Python version" : "Base interpreter"}
|
||||||
/>
|
|
||||||
<IconButton
|
|
||||||
icon="folder-open"
|
|
||||||
size="small"
|
|
||||||
title="Browse…"
|
|
||||||
onClick={async () => {
|
|
||||||
const p = await choosePath({ directory: false, title: "Select Base Interpreter" });
|
|
||||||
if (p) setBase(p);
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
|
{kind !== "conda" && (
|
||||||
|
<IconButton
|
||||||
|
icon="folder-open"
|
||||||
|
size="small"
|
||||||
|
title="Browse…"
|
||||||
|
onClick={async () => {
|
||||||
|
const p = await choosePath({ directory: false, title: "Select Base Interpreter" });
|
||||||
|
if (p) setBase(p);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.note}>{note}</div>
|
<div className={styles.note}>{note}</div>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -68,6 +68,8 @@ export function PythonInterpreterPage() {
|
|||||||
const [activate, setActivate] = useSetting<boolean>("languages.python.activateVirtualenv");
|
const [activate, setActivate] = useSetting<boolean>("languages.python.activateVirtualenv");
|
||||||
const root = useProject((s) => s.project?.root ?? null);
|
const root = useProject((s) => s.project?.root ?? null);
|
||||||
const [auto, setAuto] = useState<string | null>(null);
|
const [auto, setAuto] = useState<string | null>(null);
|
||||||
|
// Bumped when an environment is created: it may reuse the configured path, whose state changed.
|
||||||
|
const [created, setCreated] = useState(0);
|
||||||
// Detected interpreters plus the ones added to (or hidden from) the IDE-wide list.
|
// Detected interpreters plus the ones added to (or hidden from) the IDE-wide list.
|
||||||
const { detected, rows, hidden } = usePythonInterpreters({ withProjects: false });
|
const { detected, rows, hidden } = usePythonInterpreters({ withProjects: false });
|
||||||
const extras = useMemo(
|
const extras = useMemo(
|
||||||
@@ -91,7 +93,7 @@ export function PythonInterpreterPage() {
|
|||||||
return () => {
|
return () => {
|
||||||
live = false;
|
live = false;
|
||||||
};
|
};
|
||||||
}, [root]);
|
}, [root, created]);
|
||||||
|
|
||||||
// The interpreter runs resolve to: the configured one while it exists, else the fallback.
|
// The interpreter runs resolve to: the configured one while it exists, else the fallback.
|
||||||
const [resolved, setResolved] = useState<{ interpreter: string; path: string | null } | null>(null);
|
const [resolved, setResolved] = useState<{ interpreter: string; path: string | null } | null>(null);
|
||||||
@@ -104,7 +106,7 @@ export function PythonInterpreterPage() {
|
|||||||
return () => {
|
return () => {
|
||||||
live = false;
|
live = false;
|
||||||
};
|
};
|
||||||
}, [root, interpreter]);
|
}, [root, interpreter, created]);
|
||||||
// A configured interpreter whose executable is gone (PyCharm's "Invalid"): runs fall back.
|
// A configured interpreter whose executable is gone (PyCharm's "Invalid"): runs fall back.
|
||||||
const invalid =
|
const invalid =
|
||||||
!!interpreter && resolved?.interpreter === interpreter && !sameInterpreter(resolved.path, interpreter, root);
|
!!interpreter && resolved?.interpreter === interpreter && !sameInterpreter(resolved.path, interpreter, root);
|
||||||
@@ -362,6 +364,8 @@ export function PythonInterpreterPage() {
|
|||||||
onClose={() => setAdding(false)}
|
onClose={() => setAdding(false)}
|
||||||
onAdded={(path) => {
|
onAdded={(path) => {
|
||||||
setInterpreter(path);
|
setInterpreter(path);
|
||||||
|
setCreated((n) => n + 1);
|
||||||
|
reload();
|
||||||
setAdding(false);
|
setAdding(false);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -5217,7 +5217,9 @@
|
|||||||
"{count} modified action": "已修改 {count} 个操作",
|
"{count} modified action": "已修改 {count} 个操作",
|
||||||
"{count} modified actions": "已修改 {count} 个操作",
|
"{count} modified actions": "已修改 {count} 个操作",
|
||||||
"Runs “<base> -m venv <location>”; the new interpreter becomes the project interpreter.": "运行“<base> -m venv <location>”;新的解释器将成为项目解释器。",
|
"Runs “<base> -m venv <location>”; the new interpreter becomes the project interpreter.": "运行“<base> -m venv <location>”;新的解释器将成为项目解释器。",
|
||||||
"Runs “conda create -p <location>”; the new interpreter becomes the project interpreter.": "运行“conda create -p <location>”;新的解释器将成为项目解释器。",
|
"Runs “conda create -p <location> python=<version>”: a new environment with only Python in it; the new interpreter becomes the project interpreter.": "运行“conda create -p <location> python=<version>”:新建一个只包含 Python 的环境;新的解释器将成为项目解释器。",
|
||||||
|
"Python version": "Python 版本",
|
||||||
|
"Python {short}": "Python {short}",
|
||||||
"Runs “poetry env use <base>” in the project; poetry keeps the environment under its own cache directory.": "在项目中运行“poetry env use <base>”;Poetry 会将环境保存在其自己的缓存目录下。",
|
"Runs “poetry env use <base>” in the project; poetry keeps the environment under its own cache directory.": "在项目中运行“poetry env use <base>”;Poetry 会将环境保存在其自己的缓存目录下。",
|
||||||
"Runs “uv venv <location> --python <base>”; the new interpreter becomes the project interpreter.": "运行“uv venv <location> --python <base>”;新的解释器将成为项目解释器。",
|
"Runs “uv venv <location> --python <base>”; the new interpreter becomes the project interpreter.": "运行“uv venv <location> --python <base>”;新的解释器将成为项目解释器。",
|
||||||
"{vendor} {version} is unpacked into a folder of its own in {location}, where JDK detection finds it.": "{vendor} {version} 将解压到 {location} 下它自己的文件夹中,JDK 检测会在那里找到它。",
|
"{vendor} {version} is unpacked into a folder of its own in {location}, where JDK detection finds it.": "{vendor} {version} 将解压到 {location} 下它自己的文件夹中,JDK 检测会在那里找到它。",
|
||||||
|
|||||||
Reference in new issue
Заблокувати користувача