Repository navigation
Add new behaviors and appearance around deleted files - #1588
Conversation
…before deciding how to behave.
…and add support for `deleted` and `conflicted` states. By default, this does nothing cosmetic; UI themes must be updated to hook into these new class names.
…to reflect the “deleted” status of a file.
…named `tabs.enableItemStatusColoring`.
|
The |
|
Nope, taking out of draft will wait at least a bit longer. Discovered another issue (pulsar-edit/text-buffer#16) and opened another PR (pulsar-edit/text-buffer#17). Don't worry. If this isn't ready for prime time when we're ready to ship 1.133.0, it'll slip to 1.134.0. |
|
As a reminder to myself: once pulsar-edit/text-buffer#15 and pulsar-edit/text-buffer#17 both land, I'll do a When there is no project root in the window, we can't rely on a watcher to be present for resurrection detection… so instead we might want to have a fallback behavior. For instance, if we think a file has been deleted, we can re-check that assumption on demand whenever the associated editor is focused. |
…by bumping to new versions of `superstring` and `text-buffer`. Resurrection will happen via file-watcher (for project files) and when the window is foregrounded (for the active editor, if any) or when a given editor is made active. These latter strategies function as fallbacks for buffers that are from outside project roots.
…rather than `onDidDelete`/`onDidConflict`. (If the newer methods are not available on a pane item, we'll fall back to the older methods.)
…to indicate a tab's “conflicted” or “deleted” status.
|
OK, it's finally working exactly like it ought to. Here's a guide: This is our sample file. In this screenshot it exists on disk and is unmodified in the buffer. Deletion/resurrection while unmodifiedSuppose I delete the file from the terminal while the buffer is open. If The treatment in the tab is customizable by themes; it's just a new What happens when I close the tab? Depends on the value of the new This happens because we no longer automatically consider an editor to be in the “modified” state when the backing file is deleted. If the buffer was unmodified at time of deletion and has not been modified after deletion, then it never gains a “modified” status. (Despite this, But suppose I don't close the tab. Suppose I restore the original file — meaning I take the exact contents that were there previously and put them back at I'm back where I was. The file exists again, so the “deleted” state is removed; and its contents match what we already had in the buffer, so no “modified” or “conflicted” state is added. Deletion/resurrection while modifiedIn this scenario, I open the file and make some changes, but do not commit them: The editor is in the “modified” state, as we expect. If I delete Hence if I tried to close the tab now, I'd get prompted (since the buffer is still considered modified). The exact same thing will happen if I wait until file deletion and then modify the buffer. Deletion/restoration with new contentAll of the above behavior works as described because we remember what the old text was. ( So that means if I delete UnmodifiedIf the buffer was not modified at the time that the new file contents were written to ModifiedBut if we had uncommitted changes at the time of restoration, this is the textbook definition of the “conflicted“ state, albeit with extra steps. Just like if we had overwritten the file with different content, the outcome is the same even though we deleted the file first before writing the new content to At that point, conflicted semantics and behaviors apply. There's another experimental setting (introduced in 1.132) called |
|
OK, CI was green until the last commit — which only tweaks some CSS styles. Landing now! |







Here’s everything this PR does:
Bumps
@pulsar-edit/text-bufferto 15.0.0.TextBuffer::isDeleted(returnstrueif the buffer is not backed by a file on disk, but used to be).isModified(which previously always returnedtruefor buffers without a file on disk) to be more nuanced around files with “deleted” status:isModifiedwill returnfalseuntil and unless the user makes further buffer changes.isModifiedwill returntrueas it did before.The above bump implicitly changes Pulsar’s behavior when the user tries to close a buffer with “deleted” status. Because
isModifiedreturnsfalsewhen the buffer was not in a modified state at time of file deletion, such files will be able to be closed by the user without an “are you sure?” prompt. This matches VS Code’s behavior.editor.promptWhenAbandoningDeletedFilesetting. Because others have concerns about this change in behavior, this setting will (at least for now) default totrue— which means this new behavior is opt-in.Adds new behavior to the
tabspackage so that it can detect these new states (including the “conflicted” state introduced in Guard against a user saving while the text buffer is conflicted… #1478) and optionally add class names to tabs accordingly so that UI themes can style them.tabs.enableItemStatusColoringsetting, which defaults totrue.Updates the built-in UI themes to style tabs appropriately for each theme when a tab is in the “deleted” state. This mimics how VS Code represents deleted files in the tab — in red, with a strike-through effect.
tabs.enableItemStatusColoringistrue, so a community theme could style conflicted pane items however it wants.Does some other refactors in
pane.js, including some more precise API documentation.Tests were written in
text-bufferand are also written for thetabspackage. I should write at least one more for theeditor.promptWhenAbandoningDeletedFilesetting, so I’ll keep this PR in draft until that happens.