Add Ctrl-Enter: execute completion and keep commandline

This commit is contained in:
Oliver Blanthorn 2020-08-02 18:11:52 +01:00
parent e11008a616
commit d835d363b4
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3
2 changed files with 14 additions and 9 deletions

View file

@ -179,16 +179,9 @@ export function getCommandlineFns(cmdline_state: {
return messageOwnTab("controller_content", "acceptExCmd", [command])
},
execute_ex_on_completion_args: (excmd: string) => {
const args = cmdline_state.getCompletion(true)
execute_ex_on_completion_args: (excmd: string) => execute_ex_on_x(true, cmdline_state, excmd),
const cmdToExec = excmd + " " + args
cmdline_state.fns.store_ex_string(cmdToExec)
return messageOwnTab("controller_content", "acceptExCmd", [
cmdToExec,
])
},
execute_ex_on_completion: (excmd: string) => execute_ex_on_x(false, cmdline_state, excmd),
copy_completion: () => {
const command = cmdline_state.getCompletion()
@ -199,3 +192,14 @@ export function getCommandlineFns(cmdline_state: {
},
}
}
function execute_ex_on_x(args_only: boolean, cmdline_state, excmd: string){
const args = cmdline_state.getCompletion(args_only) || cmdline_state.clInput.value
const cmdToExec = (excmd ? excmd : "") + " " + args
cmdline_state.fns.store_ex_string(cmdToExec)
return messageOwnTab("controller_content", "acceptExCmd", [
cmdToExec,
])
}

View file

@ -100,6 +100,7 @@ export class default_config {
*/
exmaps = {
"<Enter>": "ex.accept_line",
"<C-Enter>": "ex.execute_ex_on_completion",
"<C-j>": "ex.accept_line",
"<C-m>": "ex.accept_line",
"<Escape>": "ex.hide_and_clear",