[gnome-builder] vim+sourceview: Fix extending selection left



commit 902c3a2701c6f0b5be0ebad8afcc5d7184fff6ca
Author: Peter Maatman <blackwolf12333 gmail com>
Date:   Mon Feb 21 22:03:49 2022 +0100

    vim+sourceview: Fix extending selection left
    
    When using vim keybindings to enter visual "selection" mode and moving
    the cursor back immediately after entering visual mode the selection
    would become empty because both marks are at the same position. The
    expected behavior is for the selection to extend to the previous
    character.
    
    Example:
    
        This is som|e| text
    
    When the cursor is on `e` and we enter visual mode, the insert and
    selection marks are where the | symbols are, insert is the left-hand | and
    selection the right-hand |.
    
    When we then use `h` to move the cursor left we would end up in the
    following situation:
    
        This is som||e text
    
    So now the insert and selection mark are in the same position, this
    makes the selection empty.
    
    We also expected to move to the situation below:
    
        This is so|me| text
    
    Such that the selection is extended to the left to include `m`.

 src/libide/sourceview/ide-source-view-movements.c | 4 ++++
 1 file changed, 4 insertions(+)
---
diff --git a/src/libide/sourceview/ide-source-view-movements.c 
b/src/libide/sourceview/ide-source-view-movements.c
index 636f8a66d..5ba2b7f8c 100644
--- a/src/libide/sourceview/ide-source-view-movements.c
+++ b/src/libide/sourceview/ide-source-view-movements.c
@@ -319,6 +319,10 @@ ide_source_view_movements_previous_char (Movement *mv)
     {
       if (gtk_text_iter_starts_line (&mv->insert))
         break;
+
+      if (gtk_text_iter_compare (&mv->insert, &mv->selection) == 0)
+        gtk_text_iter_forward_char (&mv->selection);
+
       gtk_text_iter_backward_char (&mv->insert);
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]