Closed
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
- Select File > New from the Arduino IDE menus.
- Click the downward pointing triangle button on the right side of the tab bar.
- Select "New Tab" from the menu.
- In the "Name for new file" field, type a filename that ends in
.c
,.cpp
, or.h
(e.g.,SomeTab.h
). - Click the OK button.
- Add some code that is not correctly formatted. For example:
(inappropriate leading space)
// unformatted line
- 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-05T11: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