Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Add an on snippet event to psEditor API

Aperta
#439 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
csharp, powershell
Ambito
api, tooling

Direzione di ricerca

La issue non indica file, test o punti di ingresso dell’implementazione. Inizia individuando l’API di psEditor e il percorso esistente per la gestione degli snippet, quindi chiarisci se l’obiettivo è un evento, snippet basati su comandi o entrambi. Il lavoro completato dovrebbe includere un contratto di handler definito per snippet AST, variabili e metadati, con comportamento e test che coprano l’ambito scelto.

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

Descrizione

Area-psEditor Issue-Enhancement

It'd be nice to have an event we could hook into when a snippet is used. It would be great if the
the ast of the snippet, the variables, and maybe snippet metadata like name was passed to the handler.
Alternatively (or additionally) allow editor commands to act like snippets (e.g. set "variables" to
tab to, etc.) This would enable dynamic snippets that can expand or shape the snippet based on command
output.

A very simple mock up:

/* VSCode snippet example */
"Comment Help with PowerShell Output": {
    "prefix": "CommentHelp",
    "body": [
        "<#",
        ".SYNOPSIS",
        "    ${Short description}",
        ".DESCRIPTION",
        "    ${Long description}",
        ".NOTES",
        "    Date: ${PowerShell1:Get-Date -Format MM-dd-yyyy}",
        ".LINK",
        "    ${PowerShell2:Get-Command -Module \\$MyInvocation.MyCommand.Module.Name}",
        "#>"
    ]
}
# PowerShell event handler.
$eventHandler = {
    param($snippetVariables)
    foreach ($variable in $snippetVariables) {
        if ($variable.Name.StartsWith('PowerShell')) {
            $script = [scriptblock]::Create($variable.Value)
            $output = & $script
            $psEditor.GetEditorContext().CurrentFile.InsertText($output, $variable.Range)
        }
    }
}
<#
.SYNOPSIS
    Short description
.DESCRIPTION
    Long description
.NOTES
    Date: 04-12-2017
.LINK
    Get-Function1
    Get-Function2
    Get-Function3
#>
Lingua principale
C#
Stelle
767
Fork
266
Merge medio
3g 16h
PR unite (30g)
1

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di PowerShell/PowerShellEditorServices

Tutte le issue di PowerShell/PowerShellEditorServices

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.