Clang-Format: Ensure new line at the end of files #118031
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#118031
Loading…
Reference in New Issue
No description provided.
Delete Branch "Sergey/blender:clang_format_newline"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Not all editors are configured by default to ensure new line at the
end of file.
To reduce noise and make code more uniform ensure the new lines are
ensured by the clang-format.
+1, always annoyed when this is missing...
Ditto
I think this should be committed to
blender-v4.1-release
as well, it is causing problems when merging changes into main.For example:
blender/blender@86522d9ab1
blender/blender@0801fcd6b3
There seems to be a bug with this feature where it does the opposite, removing the new line.
https://github.com/llvm/llvm-project/issues/63150
The report you've linked is about removing trailing new lines when you have multiple at the end of file. This can become more explicit configuration to ensure consistency by (so that we don't rely on default, which might change):
The commit from Sebastian you've linked has 2 trailing new lines at the end of the
sequencer_clipboard.cc
file, which then got stripped down to a single new line by Bastien's cleanup.We looked into it with Sebastian, and it seems that the
clang_format.py
script does not work well when the new line is inserted byclang-format
, leading to extra new line adde to the vim's buffer. Using the language-server integration of clang-format does not experience this issue. I also do not experience such issue with neithermake format
nor VS Code with its official clang-format extension.The proposal is:
KeepEmptyLinesAtEOF: False
to the.clang-format
clang_format.py
Vim integration need to ensure the integration properly handles new lines inserted by a formatterTo be more specific, I think that this line is the
clang_format.py
script is the issue:Here it takes the
stdout
from clang-format and splits it on every new line.The script probably didn't anticipate that clang-format would insert a new line before EOF, so in this case it instead thinks that it added a new empty line at the end of the file. And thus we get double new lines.
I switched to using the LSP for formatting, and it now matches
make format
for me.@Sergey thanks for looking into this, what you propose sounds good to me.