Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LatinIME
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
keyboard
LatinIME
Commits
b112a135
Commit
b112a135
authored
12 years ago
by
Jean Chalard
Committed by
Android (Google) Code Review
12 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Fix a race condition with backspaces"
parents
e56686f4
516b63db
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
java/src/com/android/inputmethod/latin/LatinIME.java
+5
-0
5 additions, 0 deletions
java/src/com/android/inputmethod/latin/LatinIME.java
tests/src/com/android/inputmethod/latin/InputLogicTests.java
+21
-0
21 additions, 0 deletions
tests/src/com/android/inputmethod/latin/InputLogicTests.java
with
26 additions
and
0 deletions
java/src/com/android/inputmethod/latin/LatinIME.java
+
5
−
0
View file @
b112a135
...
@@ -1717,6 +1717,11 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
...
@@ -1717,6 +1717,11 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
// If there is a selection, remove it.
// If there is a selection, remove it.
final
int
lengthToDelete
=
mLastSelectionEnd
-
mLastSelectionStart
;
final
int
lengthToDelete
=
mLastSelectionEnd
-
mLastSelectionStart
;
mConnection
.
setSelection
(
mLastSelectionEnd
,
mLastSelectionEnd
);
mConnection
.
setSelection
(
mLastSelectionEnd
,
mLastSelectionEnd
);
// Reset mLastSelectionEnd to mLastSelectionStart. This is what is supposed to
// happen, and if it's wrong, the next call to onUpdateSelection will correct it,
// but we want to set it right away to avoid it being used with the wrong values
// later (typically, in a subsequent press on backspace).
mLastSelectionEnd
=
mLastSelectionStart
;
mConnection
.
deleteSurroundingText
(
lengthToDelete
,
0
);
mConnection
.
deleteSurroundingText
(
lengthToDelete
,
0
);
}
else
{
}
else
{
// There is no selection, just delete one character.
// There is no selection, just delete one character.
...
...
This diff is collapsed.
Click to expand it.
tests/src/com/android/inputmethod/latin/InputLogicTests.java
+
21
−
0
View file @
b112a135
...
@@ -102,6 +102,27 @@ public class InputLogicTests extends InputTestsBase {
...
@@ -102,6 +102,27 @@ public class InputLogicTests extends InputTestsBase {
assertEquals
(
"delete selection"
,
EXPECTED_RESULT
,
mTextView
.
getText
().
toString
());
assertEquals
(
"delete selection"
,
EXPECTED_RESULT
,
mTextView
.
getText
().
toString
());
}
}
public
void
testDeleteSelectionTwice
()
{
final
String
STRING_TO_TYPE
=
"some text delete me some text"
;
final
int
typedLength
=
STRING_TO_TYPE
.
length
();
final
int
SELECTION_START
=
10
;
final
int
SELECTION_END
=
19
;
final
String
EXPECTED_RESULT
=
"some text some text"
;
type
(
STRING_TO_TYPE
);
// There is no IMF to call onUpdateSelection for us so we must do it by hand.
// Send once to simulate the cursor actually responding to the move caused by typing.
// This is necessary because LatinIME is bookkeeping to avoid confusing a real cursor
// move with a move triggered by LatinIME inputting stuff.
mLatinIME
.
onUpdateSelection
(
0
,
0
,
typedLength
,
typedLength
,
-
1
,
-
1
);
mInputConnection
.
setSelection
(
SELECTION_START
,
SELECTION_END
);
// And now we simulate the user actually selecting some text.
mLatinIME
.
onUpdateSelection
(
typedLength
,
typedLength
,
SELECTION_START
,
SELECTION_END
,
-
1
,
-
1
);
type
(
Constants
.
CODE_DELETE
);
type
(
Constants
.
CODE_DELETE
);
assertEquals
(
"delete selection twice"
,
EXPECTED_RESULT
,
mTextView
.
getText
().
toString
());
}
public
void
testAutoCorrect
()
{
public
void
testAutoCorrect
()
{
final
String
STRING_TO_TYPE
=
"tgis "
;
final
String
STRING_TO_TYPE
=
"tgis "
;
final
String
EXPECTED_RESULT
=
"this "
;
final
String
EXPECTED_RESULT
=
"this "
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment