hotkey: Make it possible to use ctrl+K from inside compose.

This works for other text boxes as well, but compose is the main one
that one would want to do a search from.

It's possible we'll find after doing this that "getting back into
compose" becomes a problem, but I guess we can handle that when the
time comes.
This commit is contained in:
Tim Abbott 2018-05-06 19:30:31 -07:00
parent 66edc003ca
commit df98fd5cd9
2 changed files with 6 additions and 3 deletions

View File

@ -99,7 +99,7 @@ function stubbing(func_name_to_stub, test_function) {
assert.equal(map_press(106).name, 'vim_down'); // j
assert.equal(map_down(219, false, true).name, 'escape'); // ctrl + [
assert.equal(map_down(75, false, true).name, 'search'); // ctrl + k
assert.equal(map_down(75, false, true).name, 'search_with_k'); // ctrl + k
// More negative tests.
assert.equal(map_down(47), undefined);
@ -124,7 +124,7 @@ function stubbing(func_name_to_stub, test_function) {
// CMD tests for MacOS
global.navigator.userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36";
assert.equal(map_down(219, false, false, true).name, 'escape'); // cmd + [
assert.equal(map_down(75, false, false, true).name, 'search'); // cmd + k
assert.equal(map_down(75, false, false, true).name, 'search_with_k'); // cmd + k
assert.equal(map_down(75, false, true, false), undefined); // ctrl + k

View File

@ -48,7 +48,7 @@ var keydown_unshift_mappings = {
};
var keydown_cmd_or_ctrl_mappings = {
75: {name: 'search', message_view_only: false}, // 'K'
75: {name: 'search_with_k', message_view_only: false}, // 'K'
219: {name: 'escape', message_view_only: false}, // '['
};
@ -555,6 +555,8 @@ exports.process_hotkey = function (e, hotkey) {
var height = $("#compose-textarea")[0].scrollHeight;
$("#compose-textarea").caret(Infinity).animate({ scrollTop: height }, "fast");
return true;
} else if (event_name === "search_with_k") {
// Do nothing; this allows one to use ctrl+k inside compose.
} else {
// Let the browser handle the key normally.
return false;
@ -616,6 +618,7 @@ exports.process_hotkey = function (e, hotkey) {
activity.initiate_search();
return true;
case 'search':
case 'search_with_k':
search.initiate_search();
return true;
case 'gear_menu':