Author Topic: Indent detection warnings  (Read 6950 times)

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Indent detection warnings
« on: February 24, 2014, 07:07:35 pm »
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?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Indent detection warnings
« Reply #1 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.
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!]

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Indent detection warnings
« Reply #2 on: February 24, 2014, 09:14:04 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!

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Indent detection warnings
« Reply #3 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.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Indent detection warnings
« Reply #4 on: February 25, 2014, 12:51:26 am »
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?

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Indent detection warnings
« Reply #5 on: February 25, 2014, 03:30:33 am »
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.
« Last Edit: February 25, 2014, 03:54:41 am by dmoore »