[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-bugs-dist
Subject:    [Bug 113033] S&S style indenting sometimes behaves incorrectly with
From:       Tim Hutt <tdh29 () cam ! ac ! uk>
Date:       2006-08-18 0:57:24
Message-ID: 20060818005724.25863.qmail () ktown ! kde ! org
[Download RAW message or body]

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
         
http://bugs.kde.org/show_bug.cgi?id=113033         




------- Additional Comments From tdh29 cam ac uk  2006-08-18 02:57 -------
And it goes a little something like ... this:

bool KateCSAndSIndent::startsWithLabel( int line )
{
  // Get the current line.
  KateTextLine::Ptr indentLine = doc->plainKateTextLine(line);
  const int indentFirst = indentLine->firstChar();

  // Not entirely sure what this check does.
  int attrib = indentLine->attribute(indentFirst);
  if (attrib != 0 && attrib != keywordAttrib && attrib != normalAttrib && attrib != extensionAttrib)
    return false;

  // Get the line text.
  const QString lineContents = indentLine->string();
  const int indentLast = indentLine->lastChar();
  for ( int n = indentFirst; n <= indentLast; ++n )
  {
    // Get the character as latin1. Can't use QChar::isLetterOrNumber() as that includes non 0-9 numbers.
    char c = lineContents[n].toLatin1();
    if ( c == ':' )
    {
      // See if the next character is ':' - if so, skip to the character after it.
      if ( n < lineContents.length() - 1 )
      {
        if ( lineContents[n+1].toLatin1() == ':' )
        {
          n += 2;
          continue;
        }
      }
      // Right this is the relevent ':'.
      if ( n != indentFirst && !lineContents.left(n).contains("class") )
      {
        // It is a label of some kind!
        return true;
      }
      // Just a line with a : on it, or it has 'class' before it.
      return false;
    }
    // All other characters don't indent.
    if ( !isalnum(c) && c != '_' && !isspace(c) )
    {
      return false;
    }
  }
  return false;
}

I've tested it with kate from KDE 4 (as much as I can). Almost definitely works perfectly with KDE 3.

If someone says "yes", I shall:

a) Try to remember my SVN password.
b) Give up and ask for a new one.
c) Apply this to 3.5.5 and trunk.
d) Mark as fixed.
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic