formulahendry / formulahendry/vscode-code-runner

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

Aperta
#1,255 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
2.4k
Fork
351
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia tracciando la configurazione esistente di executorMapByGlob e il modo in cui vengono risolti code-runner.cwd e la radice del progetto. Confronta l'executorMapByPath proposto e il comportamento dei glob per le directory padre, inclusi i conflitti tra le mappature; il lavoro è completo quando i file con lo stesso nome in directory diverse possono essere selezionati distintamente senza interrompere le mappature attuali.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
Ambito
tooling
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
38/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.