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

List:       kde-commits
Subject:    KDE/kdelibs/kate/part
From:       Johannes Sixt <Johannes.Sixt () telecom ! at>
Date:       2006-03-31 23:04:25
Message-ID: 1143846265.064655.2170.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 525153 by jsixt:

Use tabString() to compute the whitespace at the beginning of the line.

Now replaceWithOptimizedSpace() can be merged into optimizeLeadingSpace().

 M  +5 -26     kateautoindent.cpp  
 M  +0 -1      kateautoindent.h  


--- trunk/KDE/kdelibs/kate/part/kateautoindent.cpp #525152:525153
@@ -403,38 +403,17 @@
     }
   }
 
-  //kdDebug(13020)  << "replace With Op: " << line << " " << first_char << " " << space << endl;
-  replaceWithOptimizedSpace(line, first_char, space);
-}
+  QString new_space = tabString(space);
+  uint length = new_space.length();
 
-void KateNormalIndent::replaceWithOptimizedSpace(uint line, uint upto_column, uint space)
-{
-  uint length;
-  QString new_space;
-
-  if (useSpaces) {
-    length = space;
-    new_space.fill(' ', length);
-  }
-  else {
-    length = space / tabWidth;
-    new_space.fill('\t', length);
-
-    QString extra_space;
-    extra_space.fill(' ', space % tabWidth);
-    length += space % tabWidth;
-    new_space += extra_space;
-  }
-
-  KateTextLine::Ptr textline = doc->plainKateTextLine(line);
   uint change_from;
-  for (change_from = 0; change_from < upto_column && change_from < length; change_from++) {
+  for (change_from = 0; change_from < first_char && change_from < length; change_from++) {
     if (textline->getChar(change_from) != new_space[change_from])
       break;
   }
 
-  if (change_from < upto_column)
-    doc->removeText(KTextEditor::Range(line, change_from, line, upto_column));
+  if (change_from < first_char)
+    doc->removeText(KTextEditor::Range(line, change_from, line, first_char));
 
   if (change_from < length)
     doc->insertText(KTextEditor::Cursor(line, change_from), new_space.right(length - change_from));
--- trunk/KDE/kdelibs/kate/part/kateautoindent.h #525152:525153
@@ -325,7 +325,6 @@
   QString tabString(uint length) const;
 
   void optimizeLeadingSpace( uint line, int change );
-  void replaceWithOptimizedSpace( uint line, uint upto_column, uint space );
 
   uint  tabWidth;     //!< The number of characters simulated for a tab
   uint  indentWidth;  //!< The number of characters used when tabs are replaced by spaces
[prev in list] [next in list] [prev in thread] [next in thread] 

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