mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
add command handler to uncatch keyboard event if search is closed
This commit is contained in:
parent
d046d6cf99
commit
73e45f51f0
3 changed files with 19 additions and 7 deletions
|
|
@ -145,13 +145,19 @@ export function onSearch(uid?: string) {
|
|||
};
|
||||
}
|
||||
|
||||
export function closeSearch(uid?: string) {
|
||||
export function closeSearch(uid?: string, keyEvent?: any) {
|
||||
return (dispatch: HyperDispatch, getState: () => HyperState) => {
|
||||
const targetUid = uid || getState().sessions.activeUid!;
|
||||
if (getState().sessions.sessions[targetUid]?.search) {
|
||||
dispatch({
|
||||
type: SESSION_SEARCH_CLOSE,
|
||||
uid: targetUid
|
||||
});
|
||||
} else {
|
||||
if (keyEvent) {
|
||||
keyEvent.catched = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -325,7 +325,7 @@ export function execCommand(command: string, fn: (...args: any[]) => void, e: an
|
|||
command,
|
||||
effect() {
|
||||
if (fn) {
|
||||
fn(e);
|
||||
fn(e, dispatch);
|
||||
} else {
|
||||
rpc.emit('command', command);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,15 @@
|
|||
import {remote} from 'electron';
|
||||
import {HyperDispatch} from './hyper';
|
||||
import {closeSearch} from './actions/sessions';
|
||||
// TODO: Should be updates to new async API https://medium.com/@nornagon/electrons-remote-module-considered-harmful-70d69500f31
|
||||
|
||||
const {getDecoratedKeymaps} = remote.require('./plugins');
|
||||
|
||||
let commands: Record<string, (...args: any[]) => void> = {};
|
||||
let commands: Record<string, (event: any, dispatch: HyperDispatch) => void> = {
|
||||
'editor:search-close': (e, dispatch) => {
|
||||
dispatch(closeSearch(undefined, e));
|
||||
}
|
||||
};
|
||||
|
||||
export const getRegisteredKeys = () => {
|
||||
const keymaps = getDecoratedKeymaps();
|
||||
|
|
|
|||
Loading…
Reference in a new issue