Improve indentation width detection to better deal with Java and Vala files

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5873 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Colomban Wendling 2011-07-28 17:59:58 +00:00
parent c26cd608b7
commit 018170c130
2 changed files with 6 additions and 6 deletions

View File

@ -5,6 +5,9 @@
src/ui_utils.c, geany.glade, doc/geany.txt, doc/geany.html:
Allow to edit formerly hidden preferences in the prefs dialog
(closes #3313315, patch by Dimitar Zhekov, thanks!).
* src/document.c:
Improve indentation width detection to better deal with Java
and Vala files.
2011-06-26 Colomban Wendling <colomban(at)geany(dot)org>

View File

@ -1023,18 +1023,15 @@ static gint detect_indent_width(GeanyEditor *editor, GeanyIndentType type)
for (i = G_N_ELEMENTS(widths) - 1; i >= 0; i--)
{
if ((width % (i + 2)) == 0)
{
widths[i]++;
break;
}
}
}
count = 0;
width = iprefs->width;
for (i = 0; i < (gint)G_N_ELEMENTS(widths); i++)
for (i = G_N_ELEMENTS(widths) - 1; i >= 0; i--)
{
/* give small lengths higher weight not for nested blocks to confuse detection */
if (widths[i] > count * 4)
/* give large indents higher weight not to be fooled by spurious indents */
if (widths[i] >= count * 1.5)
{
width = i + 2;
count = widths[i];