summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ui/inputwidget.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index c9779ff0..50b12d1f 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -969,11 +969,11 @@ static void textOfLinesWasChanged_InputWidget_(iInputWidget *d, iRangei lineRang
969static void insertRange_InputWidget_(iInputWidget *d, iRangecc range) { 969static void insertRange_InputWidget_(iInputWidget *d, iRangecc range) {
970 iRangecc nextRange = { range.end, range.end }; 970 iRangecc nextRange = { range.end, range.end };
971 const int firstModified = d->cursor.y; 971 const int firstModified = d->cursor.y;
972 for (;; range = nextRange) { 972 for (; !isEmpty_Range(&range); range = nextRange) {
973 /* If there's a newline, we'll need to break and begin a new line. */ 973 /* If there's a newline, we'll need to break and begin a new line. */
974 const char *newline = iStrStrN(range.start, "\n", size_Range(&range)); 974 const char *newline = iStrStrN(range.start, "\n", size_Range(&range));
975 if (newline) { 975 if (newline) {
976 nextRange = (iRangecc){ newline + 1, range.end }; 976 nextRange = (iRangecc){ iMin(newline + 1, range.end), range.end };
977 range.end = newline; 977 range.end = newline;
978 } 978 }
979 iInputLine *line = cursorLine_InputWidget_(d); 979 iInputLine *line = cursorLine_InputWidget_(d);