The strategy is to prefer an existing document with same path and if there is none, check if there is a document with the same inode. The latter is so that links or files that have been moved, do not create duplicate documents.
The old code used a single map for the lookup, using path::identifier_t as key (wrapping path and/or inode), though since the map is ordered, the code would occasionally fail, as the keys cannot be correctly ordered (so effectively this reworked code is a fix for an incorrect path::identifier_t::operator<).
Fixes#1052.
We now setup the indent settings when creating untitled documents where we know the folder, so that we can use potential settings scoped to that folder.
Since the document itself no longer sets this as part of regular buffer setup, we also set it when opening a document with a path, and when changing a document’s file type, although the latter is probably temporary.
Closes#305.
Presently we also set file type (and thus indirectly indent settings) when “opening” a document, but I wish to remove that code, so that one can create a document, set all desired settings, and not worry about later code overwriting these settings.
The “find in folder” will create documents, set their content, and potentially save them.
If a document is not open, it should save it without going through the content examination for file type and similar, which is part of opening a non-open document.
Presently this can only be done by right-clicking the tab and selecting the “Sticky” option — if a tab is sticky then it will not be closed when executing any of the batch close actions (Close All Tabs, Close Other Tabs, Close Tabs to the Right, and holding option down while opening a file via file browser or file chooser).
Closes#1038.
The intent of this class was to allow ad-hoc recursive/lazy walking of a directory structure and having links only visited once.
It was however only used once, and for that task, path::entries() is sufficient.
While it’s easier to execute bundle items from a text view, it doesn’t work when saving documents that are not in the current text view.
This is an intermediate refactoring step — handling should (likely) end up in the DocumentSaveHelper class, but we need to improve dealing with command execution first, and by having the callback piggyback on the normal performBundleItem: method, we (temporarily) limit the code which use the command execution API, making refactoring easier.
These are now all prefixed with what they are obtaining variables for (scope, document, bundle, …) which makes it easier to analyze/refactor the code.
Also change document_t’s settings function to document_settings.
This belongs in main(), where it is already being set.
It might however be necessary to set it when running tests, although none of the tests seems to fail w/o this.
Saving is done asynchronously so the document might be closed while being saved. This in itself is not an issue, but the “post save” function will assume it has an open document for “marking as pristine” and executing potential “document did-save” callbacks on.
The problem with this feature is that it includes all untitled documents including e.g. the current bundle item being edited. For things like ⌘T we only want to show untitled documents from the current window.
This will reset the document’s backup path but not delete the backup on disk (which can be found via the document’s identifier).
This is useful if we wish to dispose the document but reconstruct it later (e.g. during application termination).
Removed the ability to specify wether documents should open in current window or a new window — all documents opened via this API will go through the same algorithm to find where the documents should end up (more choice is just adding confusion and complexity).
Since everything about session is now contained in the DocumentController class there is no need for invoking this from elsewhere and thus no need for the previous indirection.
Previously if the custom name was set before the display name was requested, it would not allocate an untitled counter, but if set later, it would (effectively) not release the counter already allocated.