summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-07-26 22:08:50 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-07-26 22:08:50 +0300
commit3d77236ca87e3ec672f0d753f79500b64ec9552e (patch)
treee99d236a15cd3bc38df032ec3aca125abc0922a8
parent120476f8acae5524a3d5c50aeb5e7a29ffbf2b3a (diff)
InputWidget: Fixed copying a range of text
-rw-r--r--src/ui/inputwidget.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index 9fbc8529..1d036939 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -139,12 +139,14 @@ static void mergeLinesRange_(const iArray *inputLines, iRanges range, iString *m
139 if (line->range.start >= range.start && line->range.end <= range.end) { 139 if (line->range.start >= range.start && line->range.end <= range.end) {
140 append_String(merged, &line->text); /* complete */ 140 append_String(merged, &line->text); /* complete */
141 } 141 }
142 else if (line->range.start < range.start) { 142 else if (range.start <= line->range.start) {
143 appendRange_String(merged, (iRangecc){ text, text + range.end - line->range.start }); 143 appendRange_String(merged, (iRangecc){ text, text + range.end - line->range.start });
144 } 144 }
145 else { 145 else {
146 appendRange_String(merged, (iRangecc){ text + range.start - line->range.start, 146 const size_t from = range.start - line->range.start;
147 text + size_Range(&line->range) }); 147 appendRange_String(merged, (iRangecc){ text + from,
148 text + iMin(from + size_Range(&range),
149 size_Range(&line->range)) });
148 } 150 }
149 } 151 }
150} 152}