-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
editor
object in jsfile / jscommand fails to get selection
#99
Comments
There's an Obsidian/CodeMirror bug/behavior (maybe that's intentional, I don't know), that the selection is cleared when a Vim command is initiated. For this reason plugin functionalities that rely on the selection use ugly trickery that constantly saves the last selection. |
Could you please explain me how? |
It's not something you can do right now unfortunately; I will add the functionality that like |
Added a |
@esm7 Can you tell me a bit more about this hack? Cause it doesn't seem to work 100% for me. I'm trying to do exmap TransformTitlecase obcommand obsidian-editor-shortcuts:transformToTitlecase
vmap <A-ç>T :TransformTitlecase But the selection is still lost (and thus only one word gets titlecased, rather than the whole selection) |
Unfortunately that hack only applies to the internal workings of the Vimrc plugin, e.g. if you use |
Got it, thanks: exmap TransformTitlecaseSelection jscommand { editor.setSelections([selection]); this.app.commands.commands['obsidian-editor-shortcuts:transformToTitlecase'].editorCallback(editor) }
vmap <A-ç>T :TransformTitlecaseSelection |
More examples at #146 |
The
editor.getSelection()
function seems to fail in jsfile or jscommand, no matter selected with insert or visual mode.jscommand { console.log(editor.getSelection()) }
gets nothing, no matter mapped invimrc
file or put in editor command line.But
editor.getCursor()
works just fine.The text was updated successfully, but these errors were encountered: