Guarantee insert after drop

master
M66B 2 weeks ago
parent 8c02cede0b
commit d3eebcc6e1

@ -603,25 +603,28 @@ public class EditTextMultiAutoComplete extends AppCompatMultiAutoCompleteTextVie
if (this == state.source && target >= sourceStart && target <= sourceEnd) if (this == state.source && target >= sourceStart && target <= sourceEnd)
return true; return true;
Editable source = state.source.getText(); try {
source.removeSpan(state.span); Editable source = state.source.getText();
source.delete(sourceStart, sourceEnd); source.removeSpan(state.span);
if (this != state.source) { source.delete(sourceStart, sourceEnd);
state.source.invalidate(); if (this != state.source) {
state.source.post(state.source.update); state.source.invalidate();
state.source.post(state.source.update);
}
if (this == state.source && target > sourceEnd)
target -= sourceEnd - sourceStart;
target = Math.max(0, Math.min(target, edit.length()));
target = resolveDropBoundary(edit, target, null);
} finally {
String text = state.text;
int insertLength = text.length();
int spanLength = state.end - state.start;
edit.insert(target, text);
edit.setSpan(state.span, target, target + spanLength, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
setSelection(target + insertLength);
} }
if (this == state.source && target > sourceEnd)
target -= sourceEnd - sourceStart;
target = Math.max(0, Math.min(target, edit.length()));
target = resolveDropBoundary(edit, target, null);
String text = state.text;
int insertLength = text.length();
int spanLength = state.end - state.start;
edit.insert(target, text);
edit.setSpan(state.span, target, target + spanLength, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
setSelection(target + insertLength);
invalidate(); invalidate();
post(update); post(update);

Loading…
Cancel
Save