User forums > Help

Tabs-to-Spaces

(1/4) > >>

jweathers:
Hello,

Before I get into my question, I would just like to offer a BIG thanks to the people who are developing Code::Blocks! It is a really nice piece of software and I see it only getting better with time. I've been using it for the last few days, and I'm really enjoying it.

However, I'm the kind of programmer who never uses tab characters in his code. So under the Editor->General->TAB options settings I have "Use TAB character" unchecked, "TAB indents" checked, and TAB size = 3 as I like indenting 3 spaces in my code. However, I've noticed from opening the source files in VIM that Code::Blocks seems to be using TABS characters despite my settings preferences. I searched the forum, but the only comments seem to suggest that this feature works. Is there something that I am missing?

Thanks!

-John

rickg22:
Frankly I couldn't tell you... I never edit my source files except with Code::Blocks :-P

However, there is the possibility of the editor module (scintilla) to save the files NOT as requested... or maybe it's a misconfiguration problem. Anyone else has noticed it?

takeshimiya:
Hi, reporting in =)

I'm also using UseTab=false, TabIndents=true, TabSize=4.

I not only can confirm this, but while reproducing it, I encountered 3 bugs :shock: in cbEditor.

1) The one noticed by jweathers is caused by Smart Indent, and you can reproduce it by typing "{" followed by ENTER.
Note that when I say "{" is the brace without quotes.

You also can see it that is a TAB instead of 4 spaces without leaving C::B (and I double checked it in SciTE and WinHEX):
Go to Editor->General->Whitespace options->View whitespaces (tabs and spaces) and set it to ALWAYS.

Well, I found that this bug was a Yiannis's TODO :) in sdk/cbeditor.cpp @ cbEditor::OnEditorCharAdded():

In if (smartIndent) block ...


--- Code: ---// Original code:
if (b == '{')
    indent << '\t'; // TODO: decide between spaces/tabs

--- End code ---


--- Code: ---// Must be something like this:
if (b == '{')
{
    if(m_pControl->GetUseTabs())
        indent << '\t'; // 1 tab
    else
        indent << wxString(' ', m_pControl->GetTabWidth()); // n spaces
}

--- End code ---

2) This other bug is very ugly (and it took me a while to reproduce it)
How to reproduce it: Press "{" and ENTER and ENTER (without writting anything more than ENTER).
You can continue pressing ENTER and the indentation goes forever.

I guess that the bug this time is also in cbEditor::OnEditorCharAdded()'s @ else if (ch == '\n').

3) The 3rd isn't really a bug, but a design flaw.
The "{", "}", "<", and a lot of other chars in cbEditor are hardcoded to C/C++, but a lot of things in C::B are hardcoded to C/C++, so it's not THAT important.
But if you are writting a plain TXT or something, you wouldn't need Smart Indent and other things enabled.

So I think that all the Indentation and Auto-Completion functionality <maybe> can be moved to the Code-Completion Plugin.


Overall, I noticed that if something appears to be a bug of Scintilla/cbEditor, check it first if that happens in the Scintilla Editor SciTE (http://www.scintilla.org/SciTE.html).
The 3 bugs above aren't found in SciTE, so you can suppose that the bug isn't in Scintilla, but in cbEditor.


A side note: I use a lot of times SciTE instead of C::B because of minor flaws that C::B haves but SciTE Does It Right (TM) :(.
(Specially the margin thing: http://sourceforge.net/tracker/index.php?func=detail&aid=1201664&group_id=126998&atid=707419)

Bug submitted to tracker: http://sourceforge.net/tracker/index.php?func=detail&aid=1253490&group_id=126998&atid=707416 :)

thomas:
And there is a fourth that causes a tab to be inserted at the last line, causing gcc to bail out "no newline at end of line", but I don't know how to reproduce it. Happens sporadically, no clue, why.

takeshimiya:
UPDATE: I compiled and tested my little fix for the Bug 1) and it appears to work ok.

However 2) 3) and now :shock: 4) remains to be fixed  :)

Navigation

[0] Message Index

[#] Next page

Go to full version