clang-format-editor icon indicating copy to clipboard operation
clang-format-editor copied to clipboard

tabsize in style detector

Open woko54 opened this issue 1 year ago • 8 comments

Is it possible to change the default tabsize (8) to an other value. My sources use a tabsize of 4 and I can't get a usable result.

woko54 avatar Aug 04 '23 10:08 woko54

This drives me crazy! I cloned the code got it compiled but can't find where the tab size is set to 8. The Tabs of my source are interpreted as 8 (should be 4) so the rest goes totally wrong.

woko54 avatar Aug 08 '23 09:08 woko54

Hi @woko54,

Sorry for delay response, can you give me a text file, to reproduce your problem?

Kind regards, Marina

mariru27 avatar Aug 16 '23 07:08 mariru27

DRV8825.txt Thanks for answering. Here is a cpp source file I used for testing. Tabsize is 4.

woko54 avatar Aug 17 '23 09:08 woko54

It seems like your detection result is closer to LLVM style, TabWitdth = 8 is the default value specific for LLVM. If you want, you can adjust TabWitdth value from our Style Detector, and generate a clang-format file

image

What do you mean by "the rest goes totally wrong"? Let me know if is something unclear, or if I didn't answer completely to your question

Kind regards, Marina

mariru27 avatar Aug 17 '23 11:08 mariru27

The style should be "Microsoft", it will be the best match. I think the wrong tabsize is the cause for the wrong style. The tabsize should be set before the detection starts.

woko54 avatar Aug 17 '23 12:08 woko54

We have applied format (default styles: Mozila, LLVM ...) on file and selected the smallest Levenshtein distance value, that is more closer to your file (seems to be LLVM in this case), the result can be influenced by another values too

Depends which algorithm you use to find the best match

In this case I don't see how setting a tab before detection will help, I need more information to understand this idea

mariru27 avatar Aug 17 '23 12:08 mariru27

It was only a guess, to explain the (for my opinion) wrong style detection.

woko54 avatar Aug 17 '23 12:08 woko54

When the detector has completed the sample (above), I see Tabs used in the left window with a size of 8, no tabs and an indention of 2 in the right (result) window. It does not look like it should do.

woko54 avatar Aug 19 '23 11:08 woko54