[vcFormat] `space.withinInitializerListBraces`/`space.withinSquareBrackets` are not heeded inside array initialization

オープン
#14,412 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
56/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
c, cpp
領域
tooling

調査の方向性

まず、vcFormat と関連する space.withinInitializerListBraces または space.withinSquareBrackets 設定を有効にした .c ファイルで問題を再現します。配列の初期化内にある最初の指示付き初期化子を vcFormat がどのように処理するかを追跡し、その後、フォーマットによって両方の期待される例に示されたスペースが保持されることを確認します。

索引モデルが issue の本文から書いたものです。

説明

bug Feature: Code Formatting Language Service Visual Studio
Environment
  • OS and Version: Various (assuming all)
  • VS Code Version: 1.117.0
  • C/C++ Extension Version: 1.31.5
Bug Summary and Steps to Reproduce

Bug Summary:

When the setting C_Cpp.vcFormat.space.withinInitializerListBraces is set to true, vcFormat fails to add (and will actually remove) a space from between the opening brace and the first designated initializer of all struct members when part of the initialization of an array of structs.

Steps to reproduce:

  1. Ensure C_Cpp.vcFormat.space.withinInitializerListBraces is set to true
  2. Add the following lines to a .c file:
typedef struct {
    int member_a;
    int member_b;
} MyStruct_t;

MyStruct_t array_of_structs[] = {
    { .member_a = 0, .member_b = 1 },
    { .member_a = 2, .member_b = 3 },
    { .member_a = 4, .member_b = 5 },
};
  1. Format the file using vcFormat

Expected behavior:

  • The file should not change

Actual result:

typedef struct {
    int member_a;
    int member_b;
} MyStruct_t;

MyStruct_t array_of_structs[] = {
    {.member_a = 0, .member_b = 1 },
    {.member_a = 2, .member_b = 3 },
    {.member_a = 4, .member_b = 5 },
};

The same problem also appears to afflict the first designated initializer of an array with spaces enabled inside square brackets. Here are steps to reproduce:

  1. Ensure C_Cpp.vcFormat.space.withinSquareBrackets is set to true
  2. Add the following lines to a .c file:
int my_array[3] = {
    [ 0 ] = 100,
    [ 1 ] = 101,
    [ 2 ] = 102,
};
  1. Format the file using vcFormat

Expected behavior:

  • The file should not change

Actual result:

int my_array[3] = {
    [0] = 100,
    [ 1 ] = 101,
    [ 2 ] = 102,
};
Configuration and Logs
Configurations vary; the pertinent configuration options are mentioned above.

Logs will be provided if deemed necessary. I believe this should be very easily reproduced.
Other Extensions

No response

Additional context

No response

主要言語
TypeScript
スター
6.2k
フォーク
1.7k
平均マージ
14時間 46分
マージ済み PR(30日)
61

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/vscode-cpptools のほかの issue

microsoft/vscode-cpptools の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。