[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 9741924: In insert_file_contents, always set windows' point marke
From: |
Alan Mackenzie |
Subject: |
master 9741924: In insert_file_contents, always set windows' point markers. |
Date: |
Fri, 12 Nov 2021 13:44:52 -0500 (EST) |
branch: master
commit 974192413f8a81171b8fd28dfd5c081ce06d3dec
Author: Alan Mackenzie <acm@muc.de>
Commit: Alan Mackenzie <acm@muc.de>
In insert_file_contents, always set windows' point markers.
This fixes bug #51776.
* src/fileio.c (restore_window_points): Restore a w->mpoint even when that
marker originally pointed into the unchanged area near BOB or EOB. This
prevents that window's point being moved a long way from its starting place
due to the removal of the central part of the buffer by
insert_file_contents.
---
src/fileio.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/fileio.c b/src/fileio.c
index 3c13d3f..a7b1649 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3827,6 +3827,7 @@ restore_window_points (Lisp_Object window_markers,
ptrdiff_t inserted,
Lisp_Object car = XCAR (window_markers);
Lisp_Object marker = XCAR (car);
Lisp_Object oldpos = XCDR (car);
+ ptrdiff_t newpos;
if (MARKERP (marker) && FIXNUMP (oldpos)
&& XFIXNUM (oldpos) > same_at_start
&& XFIXNUM (oldpos) < same_at_end)
@@ -3834,10 +3835,12 @@ restore_window_points (Lisp_Object window_markers,
ptrdiff_t inserted,
ptrdiff_t oldsize = same_at_end - same_at_start;
ptrdiff_t newsize = inserted;
double growth = newsize / (double)oldsize;
- ptrdiff_t newpos
- = same_at_start + growth * (XFIXNUM (oldpos) - same_at_start);
- Fset_marker (marker, make_fixnum (newpos), Qnil);
+ newpos = same_at_start
+ + growth * (XFIXNUM (oldpos) - same_at_start);
}
+ else
+ newpos = XFIXNUM (oldpos);
+ Fset_marker (marker, make_fixnum (newpos), Qnil);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 9741924: In insert_file_contents, always set windows' point markers.,
Alan Mackenzie <=