дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 09:11:10 +02:00
fix(search): a Windows workspace module scope searches the module's own folder
Цей коміт міститься в:
1 джерело
db790adf2f
коміт
cd370ed89a
5 files changed
+12
-6
No files matched your search
@@ -115,7 +115,8 @@ export function declaredCatalogs(settings: string): DeclaredCatalog[] {
|
||||
}
|
||||
|
||||
const readText = (path: string) => call(commands.fsReadText(path)).catch(() => null);
|
||||
const join = (dir: string, rel: string) => (rel.startsWith("/") ? rel : `${dir}/${rel.replace(/^\.\//, "")}`);
|
||||
const join = (dir: string, rel: string) =>
|
||||
rel.startsWith("/") || /^[A-Za-z]:[\\/]/.test(rel) ? rel : `${dir}/${rel.replace(/^\.\//, "")}`;
|
||||
|
||||
/**
|
||||
* The catalogs a build script sees: those of the nearest enclosing build (its settings file).
|
||||
|
||||
@@ -41,6 +41,12 @@ describe("Find in Files module and custom scopes", () => {
|
||||
path: "/p/web",
|
||||
});
|
||||
expect(resolveFindScope({ ...base, scopeTab: "module", module: "" }, inputs)).toEqual({ kind: "project" });
|
||||
// A Windows workspace member is a drive-letter path, not one under the first project (#4069).
|
||||
const windows = { ...inputs, root: "C:/tmp/alpha" };
|
||||
expect(resolveFindScope({ ...base, scopeTab: "module", module: "C:/tmp/beta" }, windows)).toEqual({
|
||||
kind: "directory",
|
||||
path: "C:/tmp/beta",
|
||||
});
|
||||
});
|
||||
|
||||
it("named scopes resolve to file sets, files and custom patterns", () => {
|
||||
|
||||
@@ -255,9 +255,7 @@ export function resolveFindScope(o: FindOptions, inputs: ScopeInputs): SearchSco
|
||||
if (o.scopeTab === "directory" && o.directory.trim())
|
||||
return { kind: "directory", path: resolveDirectory(o.directory, root) };
|
||||
if (o.scopeTab === "module")
|
||||
return o.module && root
|
||||
? { kind: "directory", path: o.module.startsWith("/") ? o.module : `${root}/${o.module}` }
|
||||
: { kind: "project" };
|
||||
return o.module && root ? { kind: "directory", path: resolveDirectory(o.module, root) } : { kind: "project" };
|
||||
if (o.scopeTab !== "scope") return { kind: "project" };
|
||||
const custom = customScopeName(o.namedScope);
|
||||
if (custom !== null) {
|
||||
|
||||
@@ -231,6 +231,7 @@ describe("markdown preview rendering", () => {
|
||||
});
|
||||
expect(resolveLink(file, "javascript:alert(1)")).toBeNull();
|
||||
expect(joinPath("C:/repo/docs", "../a.md")).toBe("C:/repo/a.md");
|
||||
expect(joinPath("C:/repo/docs", "D:/shared/a.md")).toBe("D:/shared/a.md");
|
||||
expect(joinPath("/repo", "../../a.md")).toBe("/a.md");
|
||||
});
|
||||
|
||||
|
||||
@@ -192,9 +192,9 @@ export type LinkTarget =
|
||||
/** Directory of `file` (forward slashes). */
|
||||
const dirOf = (file: string) => file.slice(0, Math.max(0, file.lastIndexOf("/")));
|
||||
|
||||
/** Joins `rel` onto `dir`, resolving `.` / `..`. Absolute `rel` (leading `/`) is kept. */
|
||||
/** Joins `rel` onto `dir`, resolving `.` / `..`. Absolute `rel` (`/…` or `C:/…`) is kept. */
|
||||
export function joinPath(dir: string, rel: string): string {
|
||||
const parts = (rel.startsWith("/") ? rel : `${dir}/${rel}`).split("/");
|
||||
const parts = (rel.startsWith("/") || /^[A-Za-z]:\//.test(rel) ? rel : `${dir}/${rel}`).split("/");
|
||||
const out: string[] = [];
|
||||
for (const p of parts) {
|
||||
if (p === "..") {
|
||||
|
||||
Reference in new issue
Заблокувати користувача