summaryrefslogtreecommitdiff
blob: e18425a6b802ad4c83a068a62e5878c736ec4917 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
From 2d05ce37c60a157760f386badc387e2d53b2fa75 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 5 Mar 2020 16:57:16 +0100
Subject: [PATCH] justify: do not crash when the user attempts to justify an
 empty region

This fixes https://savannah.gnu.org/bugs/?57959.

Bug existed since version 4.0, since the justifying
of a marked region was introduced.
---
 src/text.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/text.c b/src/text.c
index 957938f4..4fe7eb96 100644
--- a/src/text.c
+++ b/src/text.c
@@ -1930,6 +1930,12 @@ void do_justify(bool full_justify)
 		get_region((const linestruct **)&first_par_line, &top_x,
 					(const linestruct **)&last_par_line, &bot_x, &right_side_up);
 
+		/* When the marked region is empty, do nothing. */
+		if (first_par_line == last_par_line && top_x == bot_x) {
+			statusline(NOTICE, _("Nothing changed"));
+			return;
+		}
+
 		/* Save the starting point of the marked region. */
 		was_top_lineno = first_par_line->lineno;
 		was_top_x = top_x;
-- 
2.25.2