-
Notifications
You must be signed in to change notification settings - Fork 1
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
FR: save edit history in a different location and/or as a hidden file #2
Comments
@chrisgrieser Thanks! There's an item for that in the README.md TODO section. I've actually been thinking a lot about that and the code supports it, but it has multiple issues described in the code itself: /* XXX Issues with allowing a user-configured history folder:
- any history folder will mimic the the structure of the note
directory (alternatively history files could be on a flat
directory with the name coming from a hash of the full path, but
that makes renaming more involved, and fishing for history files
less intuitive)
- due to an Obsidian design decision, folders cannot start with "."
so the user-defined history folder be visible in the file explorer
- Note this limitation is not consistently enforced through the
API:
- Obsidian does allow createBinary on a path starting with a
dot and it successfully creates the file
- Unfortunately getAbstractFileFromPath on a path starting
with a dot fails so the file can be created (which only
requires the path) but not modified (which requires a
TAbstractFile)
- because it's visible, the user can rename the edit history folder
from the obsidian UI,
- renaming the topmost directory could be supported since the
only thing needed would be to update the internal variable.
Obisidan API notifies of the top level rename and each
children, which can be ignored. This will need care depending
on the reporting order of root vs. children and the update of
the internal variable.
- if the user renames a non-top level directory then all
children history files would go out of sync, so this is a
problem.
- the Obsidian setting onChange gets called on every keystroke, so
configuring the edit history folder in settings would cause a
rename on each keystroke. There doesn't seem to be a final
changed(), hide() is not called either
- it's not clear whether the folder should be deleted if empty
- it's not clear if it's safe to just copy all the files found with
whatever extension new Setting(containerEl) .setName('Edits
folder') .setDesc('Folder to store the edit history file. Empty to
store the edit file in the same directory alongside the original
file. Due to Obsidian limitations this must start with a character
other than "."') .addText(text => text .setPlaceholder('Enter the
folder name')
.setValue(this.plugin.settings.editHistoryRootFolder)
.onChange(async (value) => { logInfo("onChange");
logInfo('Edits folder: ' + value); // Only allow top level
folders
this.plugin.settings.editHistoryRootFolder = value;
// XXX Can the folder just be renamed via the file explorer
interface? // XXX Check no dir component starts with "." // XXX
Delete edits? copy them to new folder? trash them? // XXX Ask the
user to delete folder? // XXX Ask for confirmation? // XXX Use
private apis to store in some hidden folder? await
this.plugin.saveSettings();
}));
*/ https://github.com/antoniotejada/obsidian-edit-history/blob/master/main.ts#L899 I will give it more thought, but the more I think about it and the more I use it the more I like the fact that the edit history files are alongside the notes. Leaving this open. |
Your suggestion of preceding the edit history file by "." looks the most doable, but I think it will need to use the adapter Obsidian API which is frown upon (that is for sure the case if you try to create folders starting with ".", will need to verify for files). |
I know that the pandoc reference list plugin creates files in a |
I like this addon, but the way it's storing the edited files is messing up my structure. If you can't hide or do something with the files visibly showing themselves, it would be nice to allow a subfolder to be specified. Such as all edits being migrated to a folder at the bottom of the list called .history or something and not planted directly below the file that was changed. Then if I need to see the edits, I can just go to the specified folder and pick out what I need to view edits for. |
@Aetherinox they don't show for me in the Obsididan file explorer, I guess you have enabled "detect all file extensions" under Obsidian Files & Links? To me keeping the edit history file alongside the note is a feature, not a bug. It makes edit history file backup transparent and having its own folder only makes things more complicated as I describe above, so I'm not very motivated to do anything about it. The most likely thing I may do is to put a settings toggle so the edit history filename starts with a dot, which should hide it in some operating systems, and from a cursory test also in the Obsidian file explorer even with "detect all file extensions" set. |
For the record, pandoc plugin uses the bad api, https://github.com/OliverBalfour/obsidian-pandoc/blob/68ff9e3733cc73055156455721fc736ad45c7d5e/renderer.ts#L166 |
Disabling detect all file extensions seems to address the issue of it showing, but do you know if there's a place where the recognized files are listed? Because I'm wondering why I turned that on now and must have had a reason. But with my vault being so massive, it's hard to track down where. Adding the prefix of a period would be helpful on my linux system. |
I'm not aware there's such a thing, but I just found out about detect all file extensions myself by poking around. Looking at the sources, that setting corresponds to t.prototype.isSupportedFile = function(e) {
var t = this.app;
return !!t.vault.getConfig("showUnsupportedFiles") || t.viewRegistry.isExtensionRegistered(e.extension)
} So if the extension is registered then the file will be shown in the Obsidian file explorer (and available as file suggestion in the quick picker, etc). My guess is that they are regarded as registered if they have an associated core or plugin view.
Right, note would also hide it from the Obsidian file explorer even if you have "detect all file extensions". |
@Aetherinox Boils down to calling |
This .tree-item.nav-file:has(div[data-path$=edtz]) {
display: none;
} Obsidian v1.4.9 |
That sounds like a great suggestion for the styles.css file, thanks! |
There's also files and links -> Excluded files. |
Thanks for such a great plugin. |
Files with double extensions can be problematic on some operating systems (particularly Android). I'd encourage the I also occasionally see this plugin as a contributor to Obsidian Sync issues reported to the support box, due to each device generating slightly different edit histories, and possibly the plugin not being configured to reload from Sync (See https://docs.obsidian.md/Reference/TypeScript+API/Plugin/onExternalSettingsChange). From my perspective, the ability to put the .edtz files in a dedicated folder would be ideal, so that folder can be excluded from syncing services. Having them be hidden files in the vault would also work towards this purpose. |
That's news to me, do you have specifics on what the problems are with multiple dots in the filename? The original extension cannot be trivially removed because you may have two files with the same basename (eg. test.md and text.txt). You could do char replacement but then you need to also escape the replacement char, etc (without char replacement escaping, if you change "." to "_" so the edit file is test_md.edtz then it will collide with a theoretical test_md file).
Will keep onExternalSettingsChange in mind, although looks like the failures from that should be different plugin settings on each device which doesn't look like a big deal.
Using a different folder has issues as I've mentioned in previous replies (in addition, you have to replicate the whole vault folder structure elsewhere and do folder management deleting folders when no history files are found, renaming the whole folder structure when a folder is renamed in the vault, etc). I have my own google drive sync plugin and I filter out .edtz files to be safe, although things should be safe as long as you don't edit both files at the same time, which is a sync conflict anyway and the user needs to pick which file to persist. I believe there's a corner case depending on the order the edtz and original files are sync'ed, since I think syncing the original file triggers onchange, which triggers the edtz update, but I can't remember how big of an issue it was. Can't Sync be configured to filter out files by file extension?
Right, that's my suggested solution too, disable "Detect all file extensions" in the vault. Are you suggesting any other way of hiding files? I also noticed that using a dot at the beginning of the file will also hide the file from Obsidian (I believe in all OSs) but then you say that multiple extensions are problematic, so that would be problematic too. |
Thanks for the plugin, this was actually sth, I've been looking for a while.
What I'd like to have is a method to keep the edit history files out of sight. Right now, they are saved in the same folder as the note, so when you switch to the file explorer, your folder is cluttered with files you are not going to actively work with.
So what I'd like to propose is one of two options which would accomplish that.
.
prefix (e.g..notename.md.edtz
). At least on mac and Linux, this hides those files by default.The text was updated successfully, but these errors were encountered: