Skip to content
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

Fix Format Document #3

Closed
tomv564 opened this issue Aug 15, 2017 · 2 comments
Closed

Fix Format Document #3

tomv564 opened this issue Aug 15, 2017 · 2 comments

Comments

@tomv564
Copy link
Contributor

tomv564 commented Aug 15, 2017

May affect rename as well. (any logic applying workspace edits)

Repro: (in clangd) choose Format document, receive chopped up file.

@tomv564
Copy link
Contributor Author

tomv564 commented Aug 16, 2017

Should be fixed by f3f1ace

@tomv564 tomv564 closed this as completed Aug 16, 2017
@TheAifam5
Copy link

TheAifam5 commented Jan 22, 2019

That is not fixed @tomv564 . After formatting, deletes some code and I need to wait for a while to get a formatting working properly.

In my case, the comment after '#endif' was getting slowly deleted, character by a character, from left to right, every time when I pressed my keybind.

Also try to add #define log_info(...) log (LOG_INFO, __FILE__, __LINE__, __VA_ARGS__). It's getting worser than this.

I'm using cquery in C project.

Example code:

#ifndef __LOGGER_H__
#define __LOGGER_H__

#include <stdarg.h>
#include <stdio.h>

typedef void (*log_lock_t) (void * udata, int lock);
enum { LOG_TRACE, LOG_DEBUG, LOG_INFO, LOG_WARN, LOG_ERROR, LOG_FATAL };

#define log_trace(...) log (LOG_TRACE, __FILE__, __LINE__, __VA_ARGS__)
#define log_debug(...) log (LOG_DEBUG, __FILE__, __LINE__, __VA_ARGS__)
#define log_info(...) log (LOG_INFO, __FILE__, __LINE__, __VA_ARGS__)
#define log_warn(...) log (LOG_WARN, __FILE__, __LINE__, __VA_ARGS__)
#define log_error(...) log (LOG_ERROR, __FILE__, __LINE__, __VA_ARGS__)
#define log_fatal(...) log (LOG_FATAL, __FILE__, __LINE__, __VA_ARGS__)

void log_set_udata (void * udata);
void log_set_lock (hlt_log_lock_t fn);
void log_set_fp (FILE * fp);
void log_set_level (int level);
void log_set_quiet (int enable);

void log (int level, const char * file, int line, const char * fmt, ...);

#endif  // __LOGGER_H__

Example .clang-format:

BasedOnStyle: Google
IndentPPDirectives: AfterHash
IndentWidth: '2'
Language: Cpp
DerivePointerAlignment: 'false'
PointerAlignment: Middle
ReflowComments: 'true'
SortIncludes: 'true'
SortUsingDeclarations: 'true'
SpaceBeforeParens: Always
Standard: Cpp03
TabWidth: '2'
UseTab: Never
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'false'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants