Caret position change event support #284
Replies: 5 comments 7 replies
-
a 「Every n secs」event could solve this, but a new event could do it better |
Beta Was this translation helpful? Give feedback.
-
Thank you for your suggestion, it makes perfectly sense! 🙂 It's actually listed here, but anyway good to have a new discussion for it. 👍
Quick trialI tried now to quickly find out how to create this kind of event, but didn't succeed yet. I tried to examine the following event provided by Obsidian's API: I don't have a clue about in which situation the event is fired - I was not able to fire it at all. So looks like I will not use that particular event for this, but don't know yet. Next thing to tryNext I'll try the following from CodeMirror's API ( /** Will be fired when the cursor or selection moves, or any change is made to the editor content. */
on(eventName: 'cursorActivity', handler: (instance: CodeMirror.Editor) => void): void; I just don't know yet how to hook into CodeMirror's events. Will try to figure out some time. |
Beta Was this translation helpful? Give feedback.
-
Finally some progress@HuangZhuo I have now finally been able to get the Caret moved in editor event working! 🙂 Obsidian uses CodeMirror 6 as its core editor component, and I needed to dig throught different guides and websites to learn how to write extensions for CodeMirror 6. A good thing is that now it might be a bit easier for me to develop other CodeMirror related events, too, if I ever need to. There is still some work left for me to do, e.g. clean up the code and commit it to git, and I also need to find a way to detect if the caret moved to another line, or just to another column in the same line. I also need to test it more to find out if there are any problems with it. I just got it working today, so haven't had much time to try different things. I'm planning to release this in SC |
Beta Was this translation helpful? Give feedback.
-
Variable idea:
|
Beta Was this translation helpful? Give feedback.
-
This is now released in SC version Please let me know if you have any feedback. 🙂 |
Beta Was this translation helpful? Give feedback.
-
I have a idea to use 「git blame」 to show current line change log, just like gitlens did.
Beta Was this translation helpful? Give feedback.
All reactions