microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.53k stars 1.56k forks source link

JSON error when formatting with .editorconfig #12921

Closed YifanAtBioRoboLab closed 1 week ago

YifanAtBioRoboLab commented 2 weeks ago

Environment

Bug Summary and Steps to Reproduce

Bug Summary: When .editorconfig file presents in the project, formatting c++ code will result in JSON error: conversion mismatch shown in debug output penal. As a result, the extension uses default vcFormat setting to format.

This is reproducible in version 1.22.0 or above. For version before 1.22.0 the formatting has no issue handling editorconfig file and can format code as desired.

Steps to reproduce:

  1. Install and enable C/C++ extension version v1.22.10
  2. In Preference: Open Settings(UI), ensure 'C_Cpp: Clang_format_style' set to 'file' and 'C_Cpp: Formatting' set to 'default'
  3. Unzip format_test.zip to a test folder
  4. Open format_test folder with Vscode
  5. Open test.cpp.
  6. Right click code, select 'Format Document'
  7. In 'Output' window's dropdown list, select C/C++
  8. See error:

Expected behavior: No JSON error displayed and in C++ code, 'else' should stay in the same line with '}'

Configuration and Logs

Database safe to open. LSP: (received) cpptools/formatDocument: file:///c%3A/workspace/format_test/test.cpp (id: 12) LSP: (invoked) cpptools/formatDocument: file:///c%3A/workspace/format_test/test.cpp (id: 12) JSON error: editorConfigSettings.cpp_indent_braces: conversion mismatch JSON error: editorConfigSettings.cpp_indent_preserve_within_parentheses: conversion mismatch JSON error: editorConfigSettings.cpp_indent_case_labels: conversion mismatch JSON error: editorConfigSettings.cpp_indent_case_contents: conversion mismatch JSON error: editorConfigSettings.cpp_indent_case_contents_when_block: conversion mismatch JSON error: editorConfigSettings.cpp_indent_lambda_braces_when_parameter: conversion mismatch JSON error: editorConfigSettings.cpp_indent_access_specifiers: conversion mismatch JSON error: editorConfigSettings.cpp_indent_namespace_contents: conversion mismatch JSON error: editorConfigSettings.cpp_indent_preserve_comments: conversion mismatch JSON error: editorConfigSettings.cpp_new_line_scope_braces_on_separate_lines: conversion mismatch JSON error: editorConfigSettings.cpp_new_line_close_brace_same_line_empty_type: conversion mismatch JSON error: editorConfigSettings.cpp_new_line_close_brace_same_line_empty_function: conversion mismatch JSON error: editorConfigSettings.cpp_new_line_before_catch: conversion mismatch JSON error: editorConfigSettings.cpp_new_line_before_else: conversion mismatch JSON error: editorConfigSettings.cpp_new_line_before_while_in_do_while: conversion mismatch JSON error: editorConfigSettings.cpp_space_within_parameter_list_parentheses: conversion mismatch JSON error: editorConfigSettings.cpp_space_between_empty_parameter_list_parentheses: conversion mismatch JSON error: editorConfigSettings.cpp_space_after_keywords_in_control_flow_statements: conversion mismatch JSON error: editorConfigSettings.cpp_space_within_control_flow_statement_parentheses: conversion mismatch JSON error: editorConfigSettings.cpp_space_before_lambda_open_parenthesis: conversion mismatch JSON error: editorConfigSettings.cpp_space_within_cast_parentheses: conversion mismatch JSON error: editorConfigSettings.cpp_space_after_cast_close_parenthesis: conversion mismatch JSON error: editorConfigSettings.cpp_space_within_expression_parentheses: conversion mismatch JSON error: editorConfigSettings.cpp_space_before_block_open_brace: conversion mismatch JSON error: editorConfigSettings.cpp_space_between_empty_braces: conversion mismatch JSON error: editorConfigSettings.cpp_space_before_initializer_list_open_brace: conversion mismatch JSON error: editorConfigSettings.cpp_space_within_initializer_list_braces: conversion mismatch JSON error: editorConfigSettings.cpp_space_preserve_in_initializer_list: conversion mismatch JSON error: editorConfigSettings.cpp_space_before_open_square_bracket: conversion mismatch JSON error: editorConfigSettings.cpp_space_within_square_brackets: conversion mismatch JSON error: editorConfigSettings.cpp_space_before_empty_square_brackets: conversion mismatch JSON error: editorConfigSettings.cpp_space_between_empty_square_brackets: conversion mismatch JSON error: editorConfigSettings.cpp_space_group_square_brackets: conversion mismatch JSON error: editorConfigSettings.cpp_space_within_lambda_brackets: conversion mismatch JSON error: editorConfigSettings.cpp_space_between_empty_lambda_brackets: conversion mismatch JSON error: editorConfigSettings.cpp_space_before_comma: conversion mismatch JSON error: editorConfigSettings.cpp_space_after_comma: conversion mismatch JSON error: editorConfigSettings.cpp_space_remove_around_member_operators: conversion mismatch JSON error: editorConfigSettings.cpp_space_before_inheritance_colon: conversion mismatch JSON error: editorConfigSettings.cpp_space_before_constructor_colon: conversion mismatch JSON error: editorConfigSettings.cpp_space_remove_before_semicolon: conversion mismatch JSON error: editorConfigSettings.cpp_space_after_semicolon: conversion mismatch JSON error: editorConfigSettings.cpp_space_remove_around_unary_operator: conversion mismatch Formatting document: file:///c%3A/workspace/format_test/test.cpp Formatting Engine: vcFormat

Other Extensions

No response

Additional context

No response

sean-mcmanus commented 2 weeks ago

This was a regression from https://github.com/microsoft/vscode-cpptools/pull/12579 .

sean-mcmanus commented 1 week ago

Fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/v1.22.11