Skip to content

Fix Windows path separator in tree view - #728

Merged
Jocs merged 1 commit into
marktext:masterfrom
fxha:fix-tree-view-separator
Mar 6, 2019
Merged

Jocs merged 1 commit into
marktext:masterfrom
fxha:fix-tree-view-separator

Conversation

@fxha

@fxha fxha commented Mar 6, 2019

Copy link
Copy Markdown
Contributor
Q A
Bug fix? yes
Fixed tickets #661 - only UI, not the upstream crash
License MIT

Description

Fixed wrong path separator in tree view on Windows.

@fxha
fxha requested a review from Jocs March 6, 2019 12:32
@Jocs
Jocs merged commit 9af9111 into marktext:master Mar 6, 2019
@fxha
fxha deleted the fix-tree-view-separator branch March 6, 2019 17:43
thimbleberrysystems pushed a commit to thimbleberrysystems/WordBird that referenced this pull request Jun 21, 2026
Jocs added a commit that referenced this pull request Oct 9, 2026
…5683)

The sandboxed renderer's `window.path` shim is `pathe`, which always uses
`/` (#4244, #4274), while the watcher, the main process and the Electron
shell APIs use OS-native separators (`\` on Windows). Comparing those paths
with `===` silently missed matches on Windows, which broke folder
rename/delete, new-file and tab lookups, and the Delete/F2 key guards.

This restores the Windows tree behavior that #728 fixed with the native
`path.sep`; the sandbox migration replaced node's `path` with `pathe`,
regressing it.

- Compare tree paths with `isSamePathSync` so renamed/deleted folders stop
  lingering in the sidebar.
- Use the same comparison for the new-file cache, the current-file
  highlight, tab switch/save-status and rename bookkeeping.
- Make `isPathWithinRoot` separator-insensitive so Delete/F2 reach files.
- Convert renderer `/` paths to the native separator at the shell boundary
  (`shell.trashItem` / `showItemInFolder` / `openPath`), fixing the Windows
  "Failed to parse path" error. `mt::fs::*` needs no change: fs-extra
  accepts `/` on Windows.
Jocs added a commit that referenced this pull request Oct 10, 2026
…5683) (#5689)

The sandboxed renderer's `window.path` shim is `pathe`, which always uses
`/` (#4244, #4274), while the watcher, the main process and the Electron
shell APIs use OS-native separators (`\` on Windows). Comparing those paths
with `===` silently missed matches on Windows, which broke folder
rename/delete, new-file and tab lookups, and the Delete/F2 key guards.

This restores the Windows tree behavior that #728 fixed with the native
`path.sep`; the sandbox migration replaced node's `path` with `pathe`,
regressing it.

- Compare tree paths with `isSamePathSync` so renamed/deleted folders stop
  lingering in the sidebar.
- Use the same comparison for the new-file cache, the current-file
  highlight, tab switch/save-status and rename bookkeeping.
- Make `isPathWithinRoot` separator-insensitive so Delete/F2 reach files.
- Convert renderer `/` paths to the native separator at the shell boundary
  (`shell.trashItem` / `showItemInFolder` / `openPath`), fixing the Windows
  "Failed to parse path" error. `mt::fs::*` needs no change: fs-extra
  accepts `/` on Windows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants