microsoft / microsoft/vscode-cpptools

Wrong or unchanged indentation when initializing structs.

Abierto
#7,669 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

bug Feature: Code Formatting Language Service Visual Studio
Lenguaje dominante
TypeScript
Estrellas
6.2k
Forks
1.7k
Merge medio
14 h 46 min
PR fusionados (30 d)
61

Descripción

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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Reproduce el problema usando el ejemplo de inicializador de estructuras de C incluido, con C_Cpp.formatting establecido en vcFormat y la configuración de indentación indicada. Rastrea el procesamiento de vcFormat para la inicialización de variables y las expresiones de retorno, y verifica después que la indentación resultante coincide con el diseño esperado del ejemplo.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
c, typescript, vscode
Área
developer-experience, tooling
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.