nano-devel
[Top][All Lists]
Advanced

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

[Nano-devel] [PATCH] justification: when leading whitespace exceeds fill


From: Benno Schulenberg
Subject: [Nano-devel] [PATCH] justification: when leading whitespace exceeds fill width, wrap anyway
Date: Sat, 26 May 2018 21:17:45 +0200

Pico wraps at the last blank character before or on the target column;
if there is no such blank, then it will wrap at the first blank *after*
the target column -- when it can wrap, it will wrap.  Nano should do
the same, instead of leaving the line entirely unwrapped.

This fixes https://savannah.gnu.org/bugs/?53986.
---
 src/text.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/text.c b/src/text.c
index 00e114aa..b212d7cc 100644
--- a/src/text.c
+++ b/src/text.c
@@ -1737,6 +1737,10 @@ ssize_t break_line(const char *line, ssize_t goal, bool 
snap_at_nl)
        int char_len = 0;
                /* The length of the current character, in bytes. */
 
+       /* A negative target width doesn't make any sense. */
+       if (goal < 0)
+               goal = 0;
+
        /* Find the last blank that does not overshoot the target column. */
        while (*line != '\0' && column <= goal) {
                if (is_blank_mbchar(line) || (snap_at_nl && *line == '\n')) {
-- 
2.17.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]