FormatUsingClangFormatWhenCCode and TrimTrailingWhitespace
This commit is contained in:
@@ -2,9 +2,8 @@
|
|||||||
! From a user (novice) point of view, how does it look like?
|
! From a user (novice) point of view, how does it look like?
|
||||||
|
|
||||||
- Make a fuzzy command !> grep and fuzzy over it??? (doesn't seem very useful for grep)
|
- Make a fuzzy command !> grep and fuzzy over it??? (doesn't seem very useful for grep)
|
||||||
- OpenCode :Set CodeExcludePatterns ".git/|mk
|
- Add Bool variable
|
||||||
- ClangFormatOnCCode variable
|
- Not rendering U+0009 TAB properly
|
||||||
- CleanTrailingWhitespace
|
|
||||||
|
|
||||||
- Initialize all keybindings at the start and refer using global variables?
|
- Initialize all keybindings at the start and refer using global variables?
|
||||||
- RegisterCommand should_appear_in_listing variable
|
- RegisterCommand should_appear_in_listing variable
|
||||||
|
|||||||
@@ -1514,6 +1514,19 @@ void ReopenBuffer(Buffer *buffer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SaveBuffer(Buffer *buffer) {
|
void SaveBuffer(Buffer *buffer) {
|
||||||
|
bool formatted = false;
|
||||||
|
if (FormatUsingClangFormatWhenCCode) {
|
||||||
|
bool c = EndsWith(buffer->name, ".c") || EndsWith(buffer->name, ".cpp") || EndsWith(buffer->name, ".h") || EndsWith(buffer->name, ".hpp");
|
||||||
|
if (c) {
|
||||||
|
ApplyClangFormat(buffer);
|
||||||
|
formatted = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TrimTrailingWhitespace && formatted == false) {
|
||||||
|
TrimWhitespace(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
String string = AllocCharString(scratch, buffer);
|
String string = AllocCharString(scratch, buffer);
|
||||||
bool success = WriteFile(buffer->name, string);
|
bool success = WriteFile(buffer->name, string);
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ void MoveCursorByPageSize(Window *window, int direction, bool shift = false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrimTrailingWhitespace(Buffer *buffer, bool trim_lines_with_caret = false) {
|
void TrimWhitespace(Buffer *buffer, bool trim_lines_with_caret) {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
|
|
||||||
bool is_active_view = false;
|
bool is_active_view = false;
|
||||||
|
|||||||
@@ -161,3 +161,5 @@ RegisterVariable(Float, UndoMergeTime, 0.3);
|
|||||||
RegisterVariable(Float, JumpHistoryMergeTime, 0.3);
|
RegisterVariable(Float, JumpHistoryMergeTime, 0.3);
|
||||||
RegisterVariable(String, InternetBrowser, "firefox");
|
RegisterVariable(String, InternetBrowser, "firefox");
|
||||||
RegisterVariable(String, NonCodePatterns_EndsWith, ".git/|.obj|.o|.pdb|.exe|.ilk|.ttf|.ico|.gif|.jpg|.png|.spall");
|
RegisterVariable(String, NonCodePatterns_EndsWith, ".git/|.obj|.o|.pdb|.exe|.ilk|.ttf|.ico|.gif|.jpg|.png|.spall");
|
||||||
|
RegisterVariable(Int, TrimTrailingWhitespace, 1);
|
||||||
|
RegisterVariable(Int, FormatUsingClangFormatWhenCCode, 0);
|
||||||
@@ -195,3 +195,5 @@ struct ResolvedOpen {
|
|||||||
};
|
};
|
||||||
ResolvedOpen ResolveOpen(Allocator scratch, String path, String meta);
|
ResolvedOpen ResolveOpen(Allocator scratch, String path, String meta);
|
||||||
void CenterView(WindowID window);
|
void CenterView(WindowID window);
|
||||||
|
void TrimWhitespace(Buffer *buffer, bool trim_lines_with_caret = false);
|
||||||
|
void ApplyClangFormat(Buffer *buffer);
|
||||||
Reference in New Issue
Block a user