[evolution] EHTMLEditorSelection - Last word that could fit on one line is put on the following line



commit 1173209c94a4481d09a61823c82f30625cd07901
Author: Tomas Popela <tpopela redhat com>
Date:   Fri Sep 4 11:06:51 2015 +0200

    EHTMLEditorSelection - Last word that could fit on one line is put on the following line

 e-util/e-html-editor-selection.c |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/e-util/e-html-editor-selection.c b/e-util/e-html-editor-selection.c
index 5716482..2a924dd 100644
--- a/e-util/e-html-editor-selection.c
+++ b/e-util/e-html-editor-selection.c
@@ -6128,15 +6128,26 @@ find_where_to_break_line (WebKitDOMCharacterData *node,
                }
 
                if (g_unichar_isspace (uc) || *str == '-') {
-                       if (*str == '-')
-                               last_break_position_is_dash = TRUE;
-                       else
-                               last_break_position_is_dash = FALSE;
+                       last_break_position_is_dash = *str == '-';
                        last_break_position = pos;
                }
 
-               if ((pos == max_length))
+               if ((pos == max_length)) {
+                       /* Look one character after the limit to check if there
+                        * is a character that we are allowed to break at, if so
+                        * break it there. */
+                       if (*str) {
+                               str = g_utf8_next_char (str);
+                               uc = g_utf8_get_char (str);
+
+                               if (g_unichar_isspace (uc) || *str == '-') {
+                                       last_break_position_is_dash = *str == '-';
+                                       pos++;
+                                       last_break_position = pos;
+                               }
+                       }
                        break;
+               }
 
                pos++;
                str = g_utf8_next_char (str);


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