Add switch-replace command to be able to switch to an existing buffer

pull/8675/merge^2
Gabor Pihaj 5 months ago
parent 14cd995ba2
commit b045c3068b
No known key found for this signature in database
GPG Key ID: 369D85A32437F62D

@ -702,6 +702,7 @@ fn load_editor_api(engine: &mut Engine, generate_sources: bool) {
// Arity 1
module.register_fn("editor->doc-id", cx_get_document_id);
module.register_fn("editor-switch!", cx_switch);
module.register_fn("editor-switch-replace!", cx_switch_replace);
module.register_fn("editor-set-focus!", |cx: &mut Context, view_id: ViewId| {
cx.editor.focus(view_id)
});
@ -757,6 +758,7 @@ fn load_editor_api(engine: &mut Engine, generate_sources: bool) {
template_function_arity_1("editor->doc-id");
template_function_arity_1("editor-switch!");
template_function_arity_1("editor-switch-replace!");
template_function_arity_1("editor-set-focus!");
template_function_arity_1("editor-set-mode!");
template_function_arity_1("editor-doc-in-view?");
@ -2266,6 +2268,10 @@ fn cx_switch(cx: &mut Context, doc_id: DocumentId) {
cx.editor.switch(doc_id, Action::VerticalSplit)
}
fn cx_switch_replace(cx: &mut Context, doc_id: DocumentId) {
cx.editor.switch(doc_id, Action::Replace)
}
fn cx_get_mode(cx: &mut Context) -> Mode {
cx.editor.mode
}

Loading…
Cancel
Save