From 31d7b3667c209e951934dcb70dca6ecebddc6392 Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Wed, 9 Nov 2005 04:20:55 +0000
Subject: [PATCH] tweak do_para_end() to remove the assumption that the file
 always ends in a magicline

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3123 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog  |  4 ++--
 src/move.c | 17 ++++++++++-------
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 620f65e3..2bfca09e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -40,8 +40,8 @@ CVS code -
 	- Tweak a few functions to remove the assumption that the file
 	  always ends in a magicline.  Changes to cut_line(),
 	  do_cut_till_end(), open_buffer(), read_file(), write_file(),
-	  do_last_line(), do_alt_speller(), and do_wordlinechar_count().
-	  (DLR)
+	  do_last_line(), do_para_end(), do_alt_speller(), and
+	  do_wordlinechar_count(). (DLR)
 	- Tweak a few functions to rely on fileage and filebot instead
 	  of NULL for their checks to detect the top or bottom of the
 	  file.  Changes to cut_line(), cut_to_eol(), do_page_up(),
diff --git a/src/move.c b/src/move.c
index 36053551..41a6b676 100644
--- a/src/move.c
+++ b/src/move.c
@@ -148,9 +148,6 @@ void do_para_begin(bool allow_update)
 
     check_statusblank();
 
-    openfile->current_x = 0;
-    openfile->placewewant = 0;
-
     if (openfile->current != openfile->fileage) {
 	do {
 	    openfile->current = openfile->current->prev;
@@ -158,6 +155,9 @@ void do_para_begin(bool allow_update)
 	} while (!begpar(openfile->current));
     }
 
+    openfile->current_x = 0;
+    openfile->placewewant = 0;
+
     if (allow_update)
 	edit_redraw(current_save, pww_save);
 }
@@ -178,9 +178,6 @@ void do_para_end(bool allow_update)
 
     check_statusblank();
 
-    openfile->current_x = 0;
-    openfile->placewewant = 0;
-
     while (openfile->current != openfile->filebot &&
 	!inpar(openfile->current))
 	openfile->current = openfile->current->next;
@@ -192,8 +189,14 @@ void do_para_end(bool allow_update)
 	openfile->current_y++;
     }
 
-    if (openfile->current != openfile->filebot)
+    if (openfile->current != openfile->filebot) {
 	openfile->current = openfile->current->next;
+	openfile->current_x = 0;
+	openfile->placewewant = 0;
+    } else {
+	openfile->current_x = strlen(openfile->current->data);
+	openfile->placewewant = xplustabs();
+    }
 
     if (allow_update)
 	edit_redraw(current_save, pww_save);
-- 
GitLab