Commit 2ddb38e5 authored by Darren Shen's avatar Darren Shen Committed by Commit Bot

ime: Don't throw error when getAutocorrectRange is empty.

Throwing an error spams the Chrome OS logs and sends crash reports to
Chrome. Calling getAutocorrectRange when there's no autocorrect range
is a perfectly valid use of the API (otherwise how do you know if
there's an autocorrect range or not?), so it should not be an error
condition. Return (0, 0) instead.

Change-Id: I1062e04d8447058cae0f0888c97030019f99c265
Bug: b/149796494
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2444870
Commit-Queue: Darren Shen <shend@chromium.org>
Reviewed-by: default avatarKeith Lee <keithlee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816022}
parent 902b73db
......@@ -518,12 +518,9 @@ InputMethodPrivateGetAutocorrectRangeFunction::Run() {
const auto& params = parent_params->parameters;
const gfx::Range range =
engine->GetAutocorrectRange(params.context_id, &error);
if (range.is_empty()) {
return RespondNow(Error(InformativeError(error, function_name())));
}
auto ret = std::make_unique<base::DictionaryValue>();
ret->SetInteger("start", range.start());
ret->SetInteger("end", range.end());
ret->SetInteger("start", range.is_empty() ? 0 : range.start());
ret->SetInteger("end", range.is_empty() ? 0 : range.end());
return RespondNow(OneArgument(std::move(ret)));
}
......
......@@ -636,7 +636,7 @@
}, {
"name": "getAutocorrectRange",
"type": "function",
"description": "Get the autocorrected word's bounds.",
"description": "Get the autocorrected word's bounds. Returns an empty range if there is no autocorrected word.",
"parameters": [
{
"name": "parameters",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment