Bug 109183 - replace fails in block select mode depending on how selection was made
Summary: replace fails in block select mode depending on how selection was made
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: general (other bugs)
Version First Reported In: unspecified
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-16 20:13 UTC by Raphael
Modified: 2005-10-05 18:32 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Raphael 2005-07-16 20:13:16 UTC
Version:            (using KDE KDE 3.4.1)
Installed from:    SuSE RPMs
OS:                Linux

Hi there,

to reproduce, consider some text like that one:

foo Axx xxB bar
foo xxx xxx bar
foo xxx xxx bar
foo Dxx xxC bar

now with block selection switched on, select the rectangle starting from point A down to point C and replace x by y - everything works fine.
now go back and select the same rectangle, but from point D up to point B: you will get the same selection, but this time replace won't work.
The selection can be done either with mouse or keyboard - same effect:
A to C or C to A works fine, D to B or B to D doesn't.
Comment 1 Mathieu Jobin 2005-08-13 01:50:00 UTC
duplicate of bug #97140 ???




Comment 2 Raphael 2005-10-03 12:46:50 UTC
still present in KDE 3.5alpha on kubuntu hoary
Comment 3 Christoph Cullmann 2005-10-05 18:32:50 UTC
SVN commit 467566 by cullmann:

next block selection search&replace bug

BUG: 109183


 M  +26 -4     katesearch.cpp  


--- branches/KDE/3.5/kdelibs/kate/part/katesearch.cpp #467565:467566
@@ -274,7 +274,17 @@
 {
   if( s.flags.selected )
   {
-      s.cursor = s.flags.backward ? s.selEnd : s.selBegin;
+    KateTextCursor start (s.selBegin);
+    KateTextCursor end (s.selEnd);
+
+    // recalc for block sel, to have start with lowest col, end with highest
+    if (m_view->blockSelectionMode())
+    {
+      start.setCol (QMIN(s.selBegin.col(), s.selEnd.col()));
+      end.setCol (QMAX(s.selBegin.col(), s.selEnd.col()));
+    }
+    
+    s.cursor = s.flags.backward ? end : start;
   }
   else
   {
@@ -591,12 +601,24 @@
 
     if ( found && s.flags.selected )
     {
-      if ( !s.flags.backward && KateTextCursor( foundLine, foundCol ) >= s.selEnd
-        ||  s.flags.backward && KateTextCursor( foundLine, foundCol ) < s.selBegin )
+      KateTextCursor start (s.selBegin);
+      KateTextCursor end (s.selEnd);
+
+      // recalc for block sel, to have start with lowest col, end with highest
+      if (m_view->blockSelectionMode())
+      {
+        start.setCol (QMIN(s.selBegin.col(), s.selEnd.col()));
+        end.setCol (QMAX(s.selBegin.col(), s.selEnd.col()));
+      }
+
+      if ( !s.flags.backward && KateTextCursor( foundLine, foundCol ) >= end
+        ||  s.flags.backward && KateTextCursor( foundLine, foundCol ) < start )
+      {
         found = false;
+      }
       else if (m_view->blockSelectionMode())
       {
-        if ((int)foundCol < QMAX(s.selEnd.col(), s.selBegin.col()) && (int)foundCol >= QMIN(s.selEnd.col(), s.selBegin.col()))
+        if ((int)foundCol >= start.col() && (int)foundCol < end.col())
           break;
       }
     }