microsoft / microsoft/vscode-cpptools

Getting function arguments to align automatically when hitting enter

Offen
#5,726 4 Kommentare 12 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Feature Request Feature: Code Formatting Language Service
Vorherrschende Sprache
TypeScript
Sterne
6.2k
Forks
1.7k
Ø Merge
14 Std. 46 Min.
Gemergte PRs (30 T.)
61

Beschreibung

Type: LanguageService

Describe the bug

  • OS and Version: Mac OS Mojave 10.14.6
  • VS Code Version: 1.46.1
  • C/C++ Extension Version: 0.28.3
  • Other extensions you installed (and if the issue persists after disabling them):
    • All Autocomplete
    • Microsoft C/C++ official
    • Better C++ Syntax
    • Hungry Delete

The issue persists even when running code --disable-extensions

Supposed I have code like this:

    myFunction(arg1, arg2, arg3);

In Sublime Text, when I put the cursor in front of the arg2 and hit enter, the rest of the function call moves down a line and arg2 lines up with arg1 like so:

    myFunction(arg1, 
               arg2, arg3);

However, if I do the same in VS Code, the arg2 lines up to the current indentation level:

    myFunction(arg1, 
    arg2, arg3);

I can repeatedly hit the tab key to move it over 4 spaces at a time, but since the start of arg1 is 11 spaces away, I either have to deal with a slight misalignment like so:

    myFunction(arg1, 
                arg2, arg3);

or I have to use the spacebar as well as the tab key to align it just right.

If I simply bring arg2 to the next level and use "Format Selection", I get everything to align perfectly. However, I was wondering if there's any way to get this behavior to occur automatically by hitting enter.

Note that I don't want "Format Document" to run automatically; I want to keep the rest of the file as is and just have things line up as I move them to new lines.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Das Issue nennt keine Datei oder keinen Test, identifiziert aber den C++ LanguageService und das bestehende Verhalten von Format Selection. Beginne damit, die Behandlung der Einrückung bei Enter/Zeilenumbruch zu finden und sie mit der Formatierung zu vergleichen; abgeschlossen ist es, wenn Funktionsargumente bei Enter automatisch ausgerichtet werden, ohne den Rest des Dokuments zu formatieren.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
cpp, typescript
Bereich
developer-experience, tooling
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.