News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Indent detection warnings

Started by dmoore, February 24, 2014, 07:07:35 PM

Previous topic - Next topic

dmoore

Finally discovered the indent detection setting the other day (started playing with a project that uses tab indents in its sources). Surprised that this isn't on by default!!

Wondering if it should be made more like how the automatic endline detection works, with a warning shown in an info popup when mixed tab/space indents are detected. A patch is attached. Thoughts?
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

oBFusCATed

IndentData's c-tor should be explicit. Most of the time it is better to use initializers instead of copying.
The usage of eolModeStr seems like a copy-paste mistake:)

I can't comment on the functionally though :)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

dmoore

Quote from: oBFusCATed on February 24, 2014, 08:49:01 PM
IndentData's c-tor should be explicit. Most of the time it is better to use initializers instead of copying.

Good point -- just dawned on me that you could just do "return 8" which would become "return IndentData(8,false)".

Quote
The usage of eolModeStr seems like a copy-paste mistake:)

:P

Quote
I can't comment on the functionally though :)

It's great, of course!
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

Alpha

Something of note, this function currently limits itself to scanning the first 1000 lines of a file, which can result in false negatives from the warning message added by your patch.

dmoore

Quote from: Alpha on February 24, 2014, 11:56:51 PM
Something of note, this function currently limits itself to scanning the first 1000 lines of a file, which can result in false negatives from the warning message added by your patch.


Yeah that'that's a problem. What do you propose? Scan everything? Might be prohibitively slow. Probably would be sufficiently cheap to global search for EOL+tab and EOL+space for mixed detection and retain the other logic for type/length detection. I will try that.

Another idea would be to just notify if changing from the users preferred indentation choice, but that's not quite as informative as being told that there are mixed indents.

Does the auto EOL feature have this problem?

Btw, does anyone know what the editor setting "TAB Indents" does?
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

dmoore

#5
New patch. Checks whole file for instance of tab or space at start of line. (So not perfect because you could have crap like <space><space><space><tab> in a file that wouldn't be detected as mixed.)

Still don't know what TAB Indents does... EDIT: Now I do - just sets whether pressing tab inserts a tab at the current pos, or adds a new indent level and moves the cursor to the end of it. Not a very clear name.
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]