]> git.mdlowis.com Git - projs/tide.git/commitdiff
Added logic to delete previous newline if cutting the last line of a buffer
authorMichael D. Lowis <mike.lowis@gentex.com>
Fri, 30 Jun 2017 16:02:24 +0000 (12:02 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Fri, 30 Jun 2017 16:02:24 +0000 (12:02 -0400)
inc/shortcuts.h

index fe4c903d0ec1a415951a13034e18c6545fd82827..39767c25b4427c735732abad9f91ddb7c47e4cdb 100644 (file)
@@ -31,13 +31,18 @@ static void onpaste(char* text) {
 }
 
 static void cut(void) {
+    View* view = win_view(FOCUSED);
     /* select the current line if no selection */
-    if (!view_selsize(win_view(FOCUSED)))
+    if (!view_selsize(view))
         select_line();
     /* now perform the cut */
-    char* str = view_getstr(win_view(FOCUSED), NULL);
+    char* str = view_getstr(view, NULL);
     x11_sel_set(CLIPBOARD, str);
-    if (str && *str) delete();
+    if (str && *str) {
+        delete();
+        if (view->selection.end == buf_end(&(view->buffer)))
+            view_delete(view, LEFT, false);
+    }
 }
 
 static void paste(void) {