Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Auto Format deletes first line of non-.ino sketch files #746

Closed
Assignees
Labels
@per1234

Description

Describe the bug

In addition to the .ino file extension of the Arduino programming language, Arduino sketches may contain files of other programming languages, indicated by the appropriate file extension (e.g., .c, .cpp, .h).

🐛 When the Arduino IDE's Auto Format feature is used to format a sketch file with one of these file extensions other than .ino, the first line of the sketch is erased.

To Reproduce

  1. Select File > New from the Arduino IDE menus.
  2. Click the downward pointing triangle button on the right side of the tab bar.
  3. Select "New Tab" from the menu.
  4. In the "Name for new file" field, type a filename that ends in .c, .cpp, or .h (e.g., SomeTab.h).
  5. Click the OK button.
  6. Add some code that is not correctly formatted. For example:
     // unformatted line
    
    (inappropriate leading space)
  7. Select Tools > Auto Format from the Arduino IDE menus.

🐛 The first line of the file is erased.

Expected behavior

Format the code of any supported sketch file without deleting any code.

Desktop

  • OS: Windows 10
  • Version: 2.0.0-rc3-snapshot.4c831c6
    Date: 2022年01月05日T11:13:17.867Z
  • Arduino CLI Version: 0.20.2 [13783819]
  • Arduino Language Server version: 0.6.0
  • clangd version: 13.0.0

Additional context

The issue does not occur in .ino files.


It seems similar to #543 at first glance, but it is not the same issue.


Language server logs: SomeSketch.zip


Originally reported at https://forum.arduino.cc/t/ctrl-t-deletes-first-line-s-of-file/941177

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      AltStyle によって変換されたページ (->オリジナル) /