Losing focus on the current document while editing a block of code results in incorrect scrolling
- [x] The Plugin is up to date
- [x] Obsidian is up to date
Describe the bug When the code block is in the editing state, if you switch to another page or browser or something, come back to obsidian and find that the document scrolling is heavily offset. And without using this plugin this problem does not occur, because you can edit the code block directly. It may be that the current document loses focus and then changes back to a block that cannot be edited, and then enters the editing state when focus is restored, but does not return to the original position.
To Reproduce Steps to reproduce the behavior:
- Write a long block of code.
- Entering the editing state of a code block and scroll down a bit.
- Open your browser.
- Back to Obsidian page.
Expected behavior Revert to the original scroll offset.
Screenshots If applicable, add screenshots to help explain your problem.
Occurs on
- [x] Windows
- [ ] macOS
- [ ] Linux
- [ ] Android
- [ ] iOS
Plugin version 0.4.3
Additional context The other thing that confuses me is that, in the code block editing state, it is often the original syntax highlighting colour, while there are only a few cases where the preview state syntax highlighting can be displayed.
The scroll issue is caused by how Obsidian handles code block post processors. I don't think there is anything I can do about it.
The original highlighting showing happens on large code blocks, as Obsidian hides the parts of the note that are not visible and the plugin requires the entire code block to be "loaded" for it to be able to do syntax highlighting.
I am also not updating highlights on scroll for performance reasons. Maybe something can still be improved there.
The scroll issue is caused by how Obsidian handles code block post processors. I don't think there is anything I can do about it.
Is it possible to prevent a block of code from exiting from the editing state when the note loses focus?
no, not afaik
oops, mentioned the wrong issue in that commit