Bug 122101

Summary: Text selection when searching not properly updating selection start/end position
Product: [Applications] kate Reporter: Stuart BingĂ« <skbinge>
Component: generalAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: bluedzins
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:

Description Stuart Bingë 2006-02-16 14:45:19 UTC
Version:            (using KDE KDE 3.5.1)
Installed from:    Gentoo Packages
Compiler:          g++ (GCC) 3.4.5 (Gentoo 3.4.5, ssp-3.4.5-1.0, pie-8.7.9) 
OS:                Linux

When searching for a text string (in normal/non-block mode), and when that string is matched in the current document, the match is selected. This selection, however, appears to have invalid start/end positions - even though the match string looks to be properly highlighted and copy/cut works as expected with the string, there is a problem when trying to extend or contract the selection using shift + cursor keys.

When trying to extend the selection using these keys the start of the selection block jumps from the start of the current match string to what seems to be the end of the prior selection block, meaning your current selection includes all the text between the previous match selection end and the new match selection end.

The "previous selection end" to which the start position jumps only seems to change when you move the cursor using the arrow keys, without holding shift - if you do hold shift and modify the selection block using the arrow keys, hit find again, modify the selection, etc..., the start of the selection block always jumps to the same place.
Comment 1 Andreas Kling 2006-07-10 00:24:26 UTC
SVN commit 560302 by kling:

Synchronize the "cached" selection when exposing a search match.
This makes it possible to modify the new selection.

BUG: 122101


 M  +1 -0      katesearch.cpp  
 M  +6 -0      kateview.cpp  
 M  +2 -0      kateview.h  


--- branches/KDE/3.5/kdelibs/kate/part/katesearch.cpp #560301:560302
@@ -736,6 +736,7 @@
 {
   view()->setCursorPositionInternal ( cursor.line(), cursor.col() + slen, 1 );
   view()->setSelection( cursor.line(), cursor.col(), cursor.line(), cursor.col() + slen );
+  view()->syncSelectionCache();
 }
 //END KateSearch
 
--- branches/KDE/3.5/kdelibs/kate/part/kateview.cpp #560301:560302
@@ -1373,6 +1373,12 @@
   return setSelection( KateTextCursor(startLine, startCol), KateTextCursor(endLine, endCol) );
 }
 
+void KateView::syncSelectionCache()
+{
+  m_viewInternal->selStartCached = selectStart;
+  m_viewInternal->selEndCached = selectEnd;
+}
+
 bool KateView::clearSelection()
 {
   return clearSelection(true);
--- branches/KDE/3.5/kdelibs/kate/part/kateview.h #560301:560302
@@ -238,6 +238,8 @@
     void selectLine(   const KateTextCursor& cursor );
     void selectLength( const KateTextCursor& cursor, int length );
 
+    void syncSelectionCache();
+
   //
   // KTextEditor::BlockSelectionInterface stuff
   //
Comment 2 Maciej Pilichowski 2007-10-06 20:54:13 UTC
Bug is still there, KDE 3.5.7. Please reopen.