From 8540adea9e9d651ca92f625021aba43c787547d2 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sun, 18 Jul 2021 10:02:49 +0800 Subject: [PATCH] Fix: insert space when justifying paragraph and justification starts on a space. --- word.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/word.c b/word.c index 9496982..d9d1c81 100644 --- a/word.c +++ b/word.c @@ -352,9 +352,8 @@ static int parafillnjustify( int f, int n, int justify_f) { int wbufsize ; int wordlen; /* length of current word */ int clength; /* position on line during fill */ -// int i; /* index during word copy */ int eopflag; /* Are we at the End-Of-Paragraph? */ - int firstflag; /* first word? (needs no space) */ + int firstflag = TRUE ; /* first word? (needs no space) */ struct line *eopline; /* pointer to line just past EOP */ int dotflag = 0 ; /* was the last char a period? */ int leftmarg = 0 ; /* left marginal */ @@ -391,14 +390,20 @@ static int parafillnjustify( int f, int n, int justify_f) { gotobop(FALSE, 1); /* initialize various info */ - if( justflag && leftmarg < llength(curwp->w_dotp)) + if( justflag && leftmarg < llength(curwp->w_dotp)) { setccol( leftmarg) ; + lgetchar( &c) ; + if( c == ' ' || c == '\t') + /* on a space */ + if( getccol( TRUE) < getccol( FALSE)) + /* first non space before current position */ + firstflag = FALSE ; + } clength = getccol( FALSE) ; wordlen = 0; /* scan through lines, filling words */ - firstflag = TRUE; eopflag = FALSE; while (!eopflag) { int bytes = 1;