-
Notifications
You must be signed in to change notification settings - Fork 335
Description
Is your feature request related to a problem? Please describe.
I use a tool that extracts code from fenced code blocks in Markdown files, so that users can combine code and documentation together in a single file. Currently, executorMapByGlob cannot distinguish Markdown files with the same name when they are located in different directories. For example:
.
├── 📁 foo
│ └── 📝 README.md
└── 📁 bar
└── 📝 README.md
Of course, README.md isn't usually executable. So, in general, it also isn't possible to enable execution on the above, while preventing code-runner from being able to execute the ordinary documentation-only README.md.
Describe the solution you'd like
It would be great to either enhance executorMapByGlob to support parent directories (up to the project root, i.e., the parent directory of .vscode). Alternatively, add another configuration key — similar to what exists with executorMapByFileExtension — that allows mapping by relative file path (with or without globbing). For example:
{ // // Current mapping options // "code-runner.executorMap": { "javascript": "node" }, "code-runner.executorMapByGlob": { "pom.xml": "cd $dir && mvn clean package" }, "code-runner.executorMapByFileExtension": { ".vbs": "cscript //Nologo" }, // // 1. Add mapping by path option "code-runner.executorMapByPath" // - Absolute paths could be rooted at: // - project root (parent dir of ".vscode") // - or the path specified via "code-runner.cwd" // - Relative paths might cause conflict // - resolve as you do with conflicts from "executorMapByGlob" // "code-runner.executorMapByPath": { "/a/path/to/file.ext": "foo", // absolute paths /a, /b are relative to "/b/path/to/file.ext": "bar", // project root or "code-runner.cwd" "path/to/file.ext": "baz" // conflicts with previous 2 mappings ^ }, // // 2. Or extend current "code-runner.executorMapByGlob" // to eval match against parent directories as well // - Supports absolute/relative paths as in option 1. above // "code-runner.executorMapByGlob": { "/*/path/to/file.ext": "foo", // glob does not cross path sep boundaries "/path/to/*.ext": "bar", // no conflict: "path" is not in subdir "**/path/to/*.ext": "baz", // conflicts with previous 2 entries ^ "path/to/*.ext": "quux" // identical to previous } }