Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
per1234 opened this issue Jan 10, 2022 · 2 comments · Fixed by #1019
Closed

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

per1234 opened this issue Jan 10, 2022 · 2 comments · Fixed by #1019
Assignees
Labels
conclusion: resolved Issue was resolved topic: language server Related to the Arduino Language Server type: imperfection Perceived defect in any part of project

Comments

@per1234
Copy link
Contributor

per1234 commented Jan 10, 2022

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-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

@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: language server Related to the Arduino Language Server labels Jan 10, 2022
@Pushpendra766
Copy link

Got the same issue.

@per1234 per1234 linked a pull request Jun 8, 2022 that will close this issue
4 tasks
@per1234
Copy link
Contributor Author

per1234 commented Jun 8, 2022

Closing as fixed by #1019

@per1234 per1234 closed this as completed Jun 8, 2022
@per1234 per1234 added the conclusion: resolved Issue was resolved label Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: language server Related to the Arduino Language Server type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants