From 7eb5cdb9ab609c2f3887347d5387a769c0353a01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Thor=C3=A9n?= Date: Fri, 28 Jul 2017 10:53:57 +0200 Subject: [PATCH] chat: fix #1390, selection OOB When the input field includes an unmatched " in the input-text, there's a mismatch between the parsed command-args and the length of the text field, causing text selection to be out of bounds. By bounding the new selection to a maximum of the input text, this is avoided. --- src/status_im/chat/handlers/input.cljs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/status_im/chat/handlers/input.cljs b/src/status_im/chat/handlers/input.cljs index 0bb3b7ef6c..b92668ee60 100644 --- a/src/status_im/chat/handlers/input.cljs +++ b/src/status_im/chat/handlers/input.cljs @@ -388,7 +388,8 @@ new-sel (->> command-args (take (+ 3 arg-pos)) (input-model/join-command-args) - (count)) + count + (min (count input-text))) ref (get-in chat-ui-props [current-chat-id :input-ref])] (.setNativeProps ref (clj->js {:selection {:start new-sel :end new-sel}})) - (dispatch [:update-text-selection new-sel])))))) \ No newline at end of file + (dispatch [:update-text-selection new-sel]))))))