{{ message }}
Repository navigation
Conversation
On Windows the sidebar keyboard shortcuts from marktext#5638 (rename with F2 or Enter) and marktext#5609 (move to trash with Delete) did nothing for files. The renderer normalizes the project root with pathe ('C:/docs') and builds folder nodes the same way, but file nodes come from the watcher with backslashes ('C:\docs\notes.md'), so isPathWithinRoot treated every selected file as outside the project. isPathWithinRoot now compares both with '/' when the root is a Windows path (drive letter or UNC). POSIX paths are left alone, where a backslash is part of a name. The marktext#3148 e2e test also takes the file name with path.basename, so it passes with Windows paths too.
1 of 6 tasks
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Related: #1618, #3148 (follow-up to #5638 and #5609)
Summary
On Windows, the sidebar keyboard shortcuts do nothing for files in the tree: F2 and Enter don't open the rename input (#5638), and Delete doesn't ask to move the file to the trash (#5609). Folders work.
Both checks call
isPathWithinRoot(selection, root), and on Windows a file and the root use different separators:createProjectRoot, which normalizes it withwindow.path(pathe):C:/Users/me/docsC:\Users\me\docs\notes.mdSo every selected file looks like it is outside the project.
isPathWithinRootnow compares both with/when the root is a Windows path: a drive letter, or a UNC prefix (pathe turns\\server\shareinto//server/share). POSIX roots are compared as before, since a backslash there is part of a file name.Type of change
Test plan
sidebar-rename-key.spec.tsandsidebar-trash-key.spec.tscover a Windows watcher path under a normalized root (drive letter and UNC), a sibling folder with a common prefix, and a POSIX name containing a backslash. Both new tests fail without the change.issue-1618-sidebar-rename-key.spec.ts: F2 on a file opens no rename input. With the change, all 3 pass.issue-3207-sidebar-rename-commit.spec.ts: the three tests that rename a file with F2 fail. With the change, all 4 pass.issue-3148-sidebar-delete-key.spec.ts: Delete on a file shows no confirmation. With the change, both pass.Notes for reviewers [optional]
issue-3148-sidebar-delete-key.spec.tstook the file name withsplit('/').pop(), which returns the whole path on Windows; it now usespath.basename. Only Windows exercises any of this, and e2e CI runs on Ubuntu, which is presumably why it went unnoticed.By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.
🤖 Generated with Claude Code