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

List:       kde-commits
Subject:    kdelibs/kate/part
From:       Anders Lund <anders () alweb ! dk>
Date:       2004-03-26 20:21:19
Message-ID: 20040326202119.D21459985 () office ! kde ! org
[Download RAW message or body]

CVS commit by alund: 

Using document methods for replacing tabs and removing spaces, to avoid
messing up the undo history, as suggested by cullmann.

I'll backport in time for 3.2.2, unless anyone have remarks or complains I'll
do it monday.


  M +13 -4     katebuffer.cpp   1.189


--- kdelibs/kate/part/katebuffer.cpp  #1.188:1.189
@@ -400,4 +400,9 @@ bool KateBuffer::saveFile (const QString
   uint tw = m_doc->config()->tabWidth();
 
+  // Use the document methods
+  if ( m_doc->configFlags() & KateDocument::cfReplaceTabs ||
+       m_doc->configFlags() & KateDocument::cfRemoveSpaces )
+    m_doc->editStart();
+
   for (uint i=0; i < m_lines; i++)
   {
@@ -416,6 +421,6 @@ bool KateBuffer::saveFile (const QString
           {
             QString t;
-            textLine->removeText( found, 1 );
-            textLine->insertText( found, l, t.fill(onespace, l).unicode() ); // ### \
anything more eficient? +            m_doc->editRemoveText( i, found, 1 );
+            m_doc->editInsertText( i, found, t.fill(onespace, l) ); // ### anything \
more eficient?  pos += l-1;
           }
@@ -427,7 +432,7 @@ bool KateBuffer::saveFile (const QString
       {
         pos = textLine->length() - 1;
-        int lns = textLine->lastChar();
+        uint lns = textLine->lastChar();
         if ( lns != pos )
-          textLine->removeText( lns + 1, pos - lns );
+          m_doc->editRemoveText( i, lns + 1, pos - lns );
       }
 
@@ -439,4 +444,8 @@ bool KateBuffer::saveFile (const QString
   }
 
+  if ( m_doc->configFlags() & KateDocument::cfReplaceTabs ||
+       m_doc->configFlags() & KateDocument::cfRemoveSpaces )
+    m_doc->editEnd();
+
   file.close ();
 


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

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