Bug 78258 - Smart EOL jumping with end-key
Summary: Smart EOL jumping with end-key
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Debian testing Linux
: NOR wishlist (vote)
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-03-22 21:22 UTC by Linus McCabe
Modified: 2006-08-15 17:37 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Linus McCabe 2004-03-22 21:22:40 UTC
Version:            (using KDE KDE 3.2.1)
Installed from:    Debian testing/unstable Packages
OS:          Linux

When end key is pressed more than once it should behave for EOL like home key does for BOL. Ie, first press it jumps to very end, second press (or if position is already at EOL) it jumps to the position right after the last non-whitespace character.
Comment 1 Anders Lund 2004-03-22 21:35:10 UTC
Unless anyone objects to it, I'll implement this when i get the time
Comment 2 Andreas Kling 2006-07-01 22:31:13 UTC
SVN commit 556889 by kling:

Jump to last non-whitespace character when "End" key is pressed twice (i.e when already at EOL.)

BUG: 78258


 M  +13 -0     kateviewinternal.cpp  


--- branches/KDE/3.5/kdelibs/kate/part/kateviewinternal.cpp #556888:556889
@@ -1265,6 +1265,19 @@
     }
   }
 
+  // "Smart" EOL jumping as requested in bug #78258
+  // If we're already at the end, jump to last non-space character
+  if (cursor.col() == currentRange().endCol - 1 && cursor.col() != currentRange().startCol) {
+    KateTextLine::Ptr text = textLine(cursor.line());
+    if (text) {
+      int col = text->lastChar() + 1;
+      KateTextCursor c( cursor.line(), col );
+      updateSelection( c, sel );
+      updateCursor( c );
+      return;
+    }
+  }
+
   moveEdge( right, sel );
 }
 
Comment 3 Andreas Kling 2006-07-02 00:22:27 UTC
SVN commit 556924 by kling:

Forward-port of SVN commit 556889 by kling: 
 
Jump to last non-whitespace character when "End" key is pressed twice (i.e when already at EOL.) 
   
CCBUG: 78258 


 M  +13 -0     kateviewinternal.cpp  


--- trunk/KDE/kdelibs/kate/part/kateviewinternal.cpp #556923:556924
@@ -1162,6 +1162,19 @@
     }
   }
 
+  // "Smart" EOL jumping as requested in bug #78258
+  // If we're already at the end, jump to last non-space character
+  if (m_cursor.column() == currentLayout().endCol() - 1 && m_cursor.column() != currentLayout().startCol()) {
+    KateTextLine::Ptr text = textLine( m_cursor.line() );
+    if (text) {
+      int col = text->lastChar() + 1;
+      KTextEditor::Cursor c( m_cursor.line(), col );
+      updateSelection( c, sel );
+      updateCursor( c );
+      return;
+    }
+  }
+
   moveEdge( right, sel );
 }
 
Comment 4 Andreas Kling 2006-07-02 00:50:17 UTC
SVN commit 556930 by kling:

Reworked "Smart End" to use the same logic (and configuration value) as "Smart Home".
This makes a lot more sense than 556889 (the original fix for #78258)

BUG: 106970
CCBUG: 78258


 M  +16 -11    kateviewinternal.cpp  


--- branches/KDE/3.5/kdelibs/kate/part/kateviewinternal.cpp #556929:556930
@@ -1265,20 +1265,25 @@
     }
   }
 
-  // "Smart" EOL jumping as requested in bug #78258
+  if( !(m_doc->configFlags() & KateDocument::cfSmartHome) ) {
+    moveEdge( right, sel );
+    return;
+  }
+
+  // "Smart" EOL jumping as requested in bugs #78258 and #106970
   // If we're already at the end, jump to last non-space character
-  if (cursor.col() == currentRange().endCol - 1 && cursor.col() != currentRange().startCol) {
-    KateTextLine::Ptr text = textLine(cursor.line());
-    if (text) {
-      int col = text->lastChar() + 1;
-      KateTextCursor c( cursor.line(), col );
-      updateSelection( c, sel );
-      updateCursor( c );
-      return;
-    }
+
+  KateTextCursor c = cursor;
+  int lc = textLine( c.line() )->lastChar();
+
+  if (lc < 0 || c.col() == (lc + 1)) {
+    c.setCol(currentRange().endCol - 1);
+  } else {
+    c.setCol(lc + 1);
   }
 
-  moveEdge( right, sel );
+  updateSelection( c, sel );
+  updateCursor( c, true );
 }
 
 KateLineRange KateViewInternal::range(int realLine, const KateLineRange* previous)
Comment 5 Lasse Collin 2006-08-06 11:00:24 UTC
Oh no... It makes *much* more sense to jump to the last non-whitespace character when End is pressed *twice*. I doubt that anyone actually using smart Home would prefer the current behavior of smart End.

I have quite often a space as the last character on the line when I notice that I need to fix something a few words earlier e.g. a typo. Then I press End to continue writing, but after this new feature I have to press End twice to get the cursor to the correct position.

Please change this behavior to what was requested in the original bug report. The suggested feature is useful, and combining it under the same setting with smart Home is good.
Comment 6 Thomas Zander 2006-08-09 19:07:59 UTC
I agree with Lasse;  the fact that home and end have non-mirroring behavior is ok since they are used for very different things and in different situations.
Home using the indent is a good usecase.  '[home]foo' should insert foo while honoring my indent.
See the usecase of #5 for how End is normally used.  And since its the most usefull case, I'd say optimize for that by having single end not change behavior.
So, double-end moves to last non-blank is what I'd suggest.
Comment 7 Leo Savernik 2006-08-13 16:22:09 UTC
Am Mittwoch, 9. August 2006 19:08 schrieb Thomas Zander:
> I agree with Lasse;  


I agree with both of you and can back it with a real-life use-case: Whenever I 
use kate for text editing (i. e. not programming -- yes, sometimes I really 
write plain text! :-) ), I'll sometimes interrupt the flow of writing to fix 
a mistake and then return to the end of line to continue writing.

I. e. (quotes denote limits of line, | the position of the caret)

"done. yet the result still deviates excessively |"

Now I notice the missing capital "Y" and thus press Home and Ctrl+-> twice, 
then correct it, leaving us with

"done. Y|et the result still deviates excessively "

then I press End 

"done. Yet the result still deviates excessively| "

and implying common precedence of text editors, i. e. having actually expected 
this:

"done. Yet the result still deviates excessively |"

I immediately continue writing

"done. Yet the result still deviates excessivelyfrom the theoretical optimum.| 
"

See the problem? This has happened to me just today *many times*. To a lesser 
extent, this may also hit you when coding, for example parameter lists:
"  void foo(int a, |"

To use usability newspeak: Kate's current behaviour doesn't obey the principle 
of least surprise.
Comment 8 Dominik Haumann 2006-08-15 17:37:00 UTC
I second Leo's detailed workflow example. That's also what Kurt explained in reply to my blog, and also something that I sumbled over myself.