Closed voidcontext closed 4 months ago
Is this what you're looking for?
Is this what you're looking for?
Almost: editor-switch!
is implemented as
fn cx_switch(cx: &mut Context, doc_id: DocumentId) {
cx.editor.switch(doc_id, Action::VerticalSplit)
}
But what I need is Action::Replace
instead of Action::VerticalSplit
. I am not sure what your plan is regarding the API, the action could be a parameter, or there could be named functions for each action.
Update: the problem with open
is that it resets the cursor, while switch
just brings back the buffer into the view preserving the last place of the cursor.
So I think id probably want to do one function with a parameter for the action kind. The fact that I chose vertical split was arbitrary in the first place for the most part.
That would be breaking given the current API, so maybe separate functions is fine. When I get back to my computer I can take a closer look
Either way this is functionality that I'd like to have in the API somehow
So I think id probably want to do one function with a parameter for the action kind. The fact that I chose vertical split was arbitrary in the first place for the most part.
That would be breaking given the current API, so maybe separate functions is fine. When I get back to my computer I can take a closer look
Either way this is functionality that I'd like to have in the API somehow
I think I almost got this, instead of editor-switch-replace!
I started implementing editor-switch-action!
which takes 2 parameters the doc-id and the action (pushed the changes into this PR). But I got stuck, as I am not sure how I can create an Action
instance from scheme, passing a string obviously doesn't work:
(editor-switch-action! doc-id "Replace")
Update: oh, actually, I think I found the example I was missing: https://github.com/mattwparas/steel/blob/master/examples/register_types.rs#L67-L68, I'll try this.
Update 2: d611f7f seems to be working as expected:
(editor-switch-action! doc-id (Action::Replace))
Hi @mattwparas , what do you think about having a function to be able to switch to a buffer by replacing one? This would solve my question in https://github.com/helix-editor/helix/discussions/11102.