microsoft / microsoft/vscode-cpptools
"Format Selection" will use style based of preceding function instead of `C_Cpp:Clang_format_style`
Aperta
@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:
- Select
Preferences: Open Settings (UI)from the command palette - Click on 'User'
- Enter
C_Cpp:Clang_format_stylein the search box - Paste
{ BasedOnStyle: LLVM, UseTab: Never, IndentWidth: 2, TabWidth: 2, SortIncludes: Never }into the text box - Open C++ source file
- Select method using four spaces for indentation
- Select
Format Selectionfrom the command palette - 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
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Valutazione
Questa issue non è ancora stata valutata.