DeepL: trim after expand

This commit is contained in:
M66B 2021-05-19 22:06:58 +02:00
parent 40bd69398a
commit 99f6e716a5
1 changed files with 8 additions and 9 deletions

View File

@ -1999,10 +1999,17 @@ public class FragmentCompose extends FragmentBase {
end = tmp;
}
// Create paragraph
// Expand selection at start
while (start > 0 && edit.charAt(start - 1) != '\n')
start--;
if (start == end && end < edit.length())
end++;
// Expand selection at end
while (end > 0 && end < edit.length() && edit.charAt(end - 1) != '\n')
end++;
// Trim start
while (start < edit.length() - 1 && edit.charAt(start) == '\n')
start++;
@ -2011,14 +2018,6 @@ public class FragmentCompose extends FragmentBase {
while (end > 1 && edit.charAt(end - 2) == '\n')
end--;
// Expand selection at start
while (start > 0 && edit.charAt(start - 1) != '\n')
start--;
// Expand selection at end
while (end > 0 && end < edit.length() && edit.charAt(end - 1) != '\n')
end++;
if (start < end)
return new Pair(start, end);