microsoft / microsoft/vscode-cpptools

Wrong or unchanged indentation when initializing structs.

Aperta
#7,669 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug Feature: Code Formatting Language Service Visual Studio
Lingua principale
TypeScript
Stelle
6.2k
Fork
1.7k
Merge medio
14h 46m
PR unite (30g)
61

Descrizione

Bug type: Language Service

With VSCode 1.56 (April 2021) & cpptools 1.4.1

There are problems with the indentations of struct initializers.

  • When initializing a variable, the indentation is unchanged.
  • When returning, the indentation is changed but wrong.
    • The first line is correct.
    • The rest is double-indented.
typedef struct thing {
    int a;
    int b;
} thing;

thing get_thing() {

    /* In these situations: indentation is unchanged */
    thing a = {
            10, // wrong indentation not corrected
    10 // wrong indentation not corrected
    };
    thing t = {
                .a = 10, // wrong indentation not corrected
    .b = 10 // wrong indentation not corrected
    };
    t = (thing){
        .a = 10, // had to manually indent those ones
        .b = 10 // indentation is unchanged by formatter
    };

    /* In these situations: indentation is worng */
    return (thing) {
        .a = 10, // good
            .b = 10 // wrong indentation formatted
    };
}

Configuration:

"C_Cpp.formatting": "vcFormat"
"C_Cpp.vcFormat.indent.caseLabels": true

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.

Direzione di ricerca

Riproduci il problema usando l’esempio incorporato di inizializzatore di struct C, con C_Cpp.formatting impostato su vcFormat e l’impostazione di indentazione indicata. Traccia la gestione di vcFormat per l’inizializzazione delle variabili e le espressioni di return, quindi verifica che l’indentazione risultante corrisponda al layout previsto dall’esempio.

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

Valutazione

Stack tecnologico
c, typescript, vscode
Ambito
developer-experience, tooling
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.