microsoft / microsoft/vscode-cpptools

"Format Selection" will use style based of preceding function instead of `C_Cpp:Clang_format_style`

Aperta
#10,839 7 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@michelleangela ci sta già lavorando.

Dal 19/4/2023.

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

Descrizione

Environment
  • OS and Version: Windows 11, Version 22H2 (OS Build 22621.1413)
  • VS Code Version: 1.77.2
  • C/C++ Extension Version: v1.14.5
  • If using SSH remote, specify OS of remote machine: Ubuntu 20.04.6 LTS
Bug Summary and Steps to Reproduce

Bug Summary:

I have set C_Cpp:Clang_format_style to:

{ BasedOnStyle: LLVM, UseTab: Never, IndentWidth: 2, TabWidth: 2, SortIncludes: Never }.

However, when I select a block of code that use a different number of spaces for indentation (four, for example) and select Format Selection from the command palette, the indentation does not change.

Steps to reproduce:

  1. Select Preferences: Open Settings (UI) from the command palette
  2. Click on 'User'
  3. Enter C_Cpp:Clang_format_style in the search box
  4. Paste { BasedOnStyle: LLVM, UseTab: Never, IndentWidth: 2, TabWidth: 2, SortIncludes: Never } into the text box
  5. Open C++ source file
  6. Select method using four spaces for indentation
  7. Select Format Selection from the command palette
  8. Observe that indentation of selected block does not change

Expected behavior:

Indentation of selected block does changes from four spaces to two spaces.

Configuration and Logs
LSP: textDocument/hover: file:///<redacted>.cpp (id: 2495)
LSP: cpptools/textEditorSelectionChange
LSP: cpptools/textEditorSelectionChange
LSP: cpptools/textEditorSelectionChange
LSP: cpptools/textEditorSelectionChange
LSP: cpptools/textEditorSelectionChange
LSP: cpptools/textEditorSelectionChange
LSP: cpptools/textEditorSelectionChange
LSP: cpptools/textEditorSelectionChange
LSP: cpptools/getCodeActions: file:///<redacted>.cpp (id: 2496)
LSP: cpptools/formatRange: file:///<redacted>.cpp (id: 2497)
Formatting document: file:///<redacted>.cpp
Formatting Engine: clangFormat
Other Extensions

No response

Additional context

No response

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.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.