obsidian-git
obsidian-git copied to clipboard
Make diff views extend FileView
There is a way to work around this limitation for DiffViews:
This class is not extending
FileView, because it needs aTFile, which is not possible for dot files like.gitignore, which this editor should support as well.`
by using the getFile utility function from the obsidian-dev-utils package, which creates a TFile from any vault path you provide (hidden files included).
Would there be benefits/drawbacks to refactoring the DiffViews to extend FileView?
I know it would help with my plugin integration, so i can easily sync my views with with the current diff view state. But i could also probably make it work without this, with some gimmicks.
Regarding the obsidian-dev-utils package, the dev knows the Obsidian API very well, so it has a lot of other useful utilities that may be of use, like a dev script that automatically transfers your build output to the obsidian plugins folder, so you don't have to manually transfer files or develop from within that subfolder. (Also allows passing custom esbuild instructions)
But of course for this, the refactoring cost could outweigh the benefits.
I prefer the current way, because Obsidian or other plugins might want to interact with the TFile of the diff view, which could fail if they expect it to be actually tracked by Obsidian. (A quick example would be files in the .obsidian directory) I would rather not take that risk.
And a quick note to the dev script. I just symlinked my main.js and styles.css from my development directory to the obsidian-git directory of my testing vault.
Yeah, i agree on that then.
I can still listen to diff view being opened using active-leaf-change, but is it currently possible to listen to or react when the diff view state changes?
I don't think there is a way currently. How much do you need this feature? I think the only way would be to emit an event on the leaf of the diff view.
How much do you need this feature?
It would be nice to have it, but i'm going to see if i can find a workaround for this, specifically if there's a way to listen to setViewState().
I'm going to close this for now