Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Fixing bug when ListenableEditingState is provided initialState with a valid composing range, android.view.inputmethod.BaseInputConnection.setComposingRegion(int, int) has NPE #30916

Merged
merged 4 commits into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ void didChangeEditingState(
public ListenableEditingState(
@Nullable TextInputChannel.TextEditState initialState, @NonNull View view) {
super();
if (initialState != null) {
setEditingState(initialState);
}

Editable self = this;
mDummyConnection =
Expand All @@ -72,6 +69,10 @@ public Editable getEditable() {
return self;
}
};

if (initialState != null) {
setEditingState(initialState);
}
}

public ArrayList<TextEditingDelta> extractBatchTextEditingDeltas() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ public void setUp() {
MockitoAnnotations.openMocks(this);
}

@Test
public void testConstructor() {
// When provided valid composing range, should not fail
new ListenableEditingState(
new TextInputChannel.TextEditState("hello", 1, 4, 1, 4),
new View(RuntimeEnvironment.application));
}

// -------- Start: Test BatchEditing -------
@Test
public void testBatchEditing() {
Expand Down