File patch-r897715.diff of Package kdelibs4

Subject: fix kate moving cursor when Wrap cursor is off
From: wstephenson@suse.de
Bug: 
Patch-upstream: 897715
--- kate/view/kateview.cpp	(revision 897714)
+++ kate/view/kateview.cpp	(revision 897715)
@@ -1275,6 +1275,9 @@ void KateView::updateDocumentConfig()
 
   m_updatingDocumentConfig = false;
 
+  // maybe block selection or wrap-cursor mode changed
+  ensureCursorColumnValid();
+
   m_viewInternal->updateView (true);
 
   m_renderer->setTabWidth (m_doc->config()->tabWidth());
@@ -1322,6 +1325,21 @@ void KateView::updateFoldingConfig ()
       a->setEnabled (m_doc->highlight() && m_doc->highlight()->allowsFolding());
 }
 
+void KateView::ensureCursorColumnValid()
+{
+  KTextEditor::Cursor c = m_viewInternal->getCursor();
+
+  // make sure the cursor is valid:
+  // - in block selection mode or if wrap cursor is off, the colum is arbitrary
+  // - otherwise: it's bounded by the line length
+  if (!blockSelectionMode() && wrapCursor()
+      && (c.isValid() || c.column() > m_doc->lineLength(c.line())))
+  {
+    c.setColumn(m_doc->kateTextLine(cursorPosition().line())->length());
+    setCursorPosition(c);
+  }
+}
+
 //BEGIN EDIT STUFF
 void KateView::editStart ()
 {
@@ -1893,17 +1911,9 @@ bool KateView::setBlockSelectionMode (bo
 
     m_toggleBlockSelection->setChecked( blockSelectionMode() );
 
-    KTextEditor::Cursor c = m_viewInternal->getCursor();
-
     // when leaving block selection mode, if cursor is at an invalid position or past the end of the
     // line, move the cursor to the last column of the current line unless cursor wrapping is off
-    if(!blockSelectionMode() && !wrapCursor() &&
-            (c.isValid() || c.column() > m_doc->lineLength(c.line())))
-    {
-      KTextEditor::Cursor cursorAtEndOfLine(cursorPosition());
-      cursorAtEndOfLine.setColumn(m_doc->kateTextLine(cursorPosition().line())->length());
-      setCursorPosition(cursorAtEndOfLine);
-    }
+    ensureCursorColumnValid();
   }
 
   return true;
--- kate/view/kateview.h	(revision 897714)
+++ kate/view/kateview.h	(revision 897715)
@@ -317,6 +317,8 @@ class KateView : public KTextEditor::Vie
     bool lineHasSelected (int line);
     bool lineIsSelection (int line);
 
+    void ensureCursorColumnValid();
+
     void tagSelection (const KTextEditor::Range &oldSelection);
 
     void selectWord(   const KTextEditor::Cursor& cursor );
--- kate/view/kateviewinternal.cpp	(revision 897714)
+++ kate/view/kateviewinternal.cpp	(revision 897715)
@@ -859,12 +859,12 @@ public:
       return *this;
     }
 
-    const bool blockSelectionMode = m_vi->view()->blockSelection();
+    const bool noWrapCursor = m_vi->view()->blockSelection() || !m_vi->m_view->wrapCursor();
     int maxColumn = -1;
     if (n >= 0) {
       for (int i = 0; i < n; i++) {
         if (m_column >= thisLine->length()) {
-          if (!blockSelectionMode) {
+          if (!noWrapCursor) {
             break;
 
           } else if (m_vi->view()->dynWordWrap()) {
Index: kate/view/kateview.cpp
===================================================================
Index: kate/view/kateview.h
===================================================================
Index: kate/view/kateviewinternal.cpp
===================================================================
openSUSE Build Service is sponsored by