Summary
When a bound text editor destination's file is renamed, the binding still points to the old URI. While less critical than file deletion (the file still exists at the new path), the stale binding is incorrect and should be cleaned up automatically.
Following the same established pattern as terminal-close, editor-close, and file-deletion auto-unbind, RangeLink should listen to vscode.workspace.onDidRenameFiles and auto-unbind when a renamed file matches the bound text editor destination.
Details
Listener registration
Add an onDidRenameFiles listener in BoundDestinationLifecycle, co-located with the existing onDidCloseTerminal, onDidCloseTextDocument, and onDidDeleteFiles listeners.
Detection logic
When onDidRenameFiles fires with a FilesRenameEvent containing one or more { oldUri, newUri } pairs, compare each oldUri against the current bound destination's URI (for text-editor type destinations). If matched, trigger the unbind.
Unbind behavior
- Call
unbind({ silent: true }) to remove the binding without a full toast.
- Show a single merged
setStatusBarMessage: "Unbound from Text Editor (name) - file renamed"
- Plain text, no checkmark prefix
- Use the same merged-message pattern as the file-deletion unbind (gather pending edits, show one combined message)
Messages
Add a new message code and entry to messages.en.ts for the status bar message text.
Tests
- Unit tests for the new
onDidRenameFiles listener, following the same pattern as existing lifecycle listener tests
- Integration tests covering the rename-triggers-unbind flow (via
vscode.workspace.fs.rename() or simulated rename event)
Priority
This is lower priority than file deletion. A renamed file still exists at the new path; the user can re-bind without data loss. Implement after the file-deletion auto-unbind is fully shipped and verified.
Dependencies
- Depends on: BoundDestinationLifecycle extraction (adds listener in the lifecycle module)
- Blocks: nothing
Acceptance criteria
- Renaming an open file that is bound as a text-editor destination auto-unbinds the destination
- Status bar message shows
"Unbound from Text Editor (name) - file renamed" without a checkmark
- Renaming an unrelated file does not trigger unbind
- Existing lifecycle listeners (terminal-close, editor-close, file-deletion) continue to work unchanged
Summary
When a bound text editor destination's file is renamed, the binding still points to the old URI. While less critical than file deletion (the file still exists at the new path), the stale binding is incorrect and should be cleaned up automatically.
Following the same established pattern as terminal-close, editor-close, and file-deletion auto-unbind, RangeLink should listen to
vscode.workspace.onDidRenameFilesand auto-unbind when a renamed file matches the bound text editor destination.Details
Listener registration
Add an
onDidRenameFileslistener inBoundDestinationLifecycle, co-located with the existingonDidCloseTerminal,onDidCloseTextDocument, andonDidDeleteFileslisteners.Detection logic
When
onDidRenameFilesfires with aFilesRenameEventcontaining one or more{ oldUri, newUri }pairs, compare eacholdUriagainst the current bound destination's URI (for text-editor type destinations). If matched, trigger the unbind.Unbind behavior
unbind({ silent: true })to remove the binding without a full toast.setStatusBarMessage:"Unbound from Text Editor (name) - file renamed"Messages
Add a new message code and entry to
messages.en.tsfor the status bar message text.Tests
onDidRenameFileslistener, following the same pattern as existing lifecycle listener testsvscode.workspace.fs.rename()or simulated rename event)Priority
This is lower priority than file deletion. A renamed file still exists at the new path; the user can re-bind without data loss. Implement after the file-deletion auto-unbind is fully shipped and verified.
Dependencies
Acceptance criteria
"Unbound from Text Editor (name) - file renamed"without a checkmark