formulahendry / formulahendry/vscode-code-runner

[Feature request] Allow maps to match relative paths or parent directories

Offen
#1,255 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
TypeScript
Sterne
2.4k
Forks
351
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

**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:

```jsonc
{
//
// 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
}
}

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Beginne damit, die bestehende Konfiguration von executorMapByGlob und die Auflösung von code-runner.cwd und dem Projektstammverzeichnis nachzuverfolgen. Vergleiche das vorgeschlagene executorMapByPath und das Glob-Verhalten für übergeordnete Verzeichnisse, einschließlich Konflikten zwischen Zuordnungen; die Arbeit ist abgeschlossen, wenn Dateien mit demselben Namen in verschiedenen Verzeichnissen eindeutig ausgewählt werden können, ohne die aktuellen Zuordnungen zu beeinträchtigen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
tooling
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
38/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.