Handle forward-slash UNC terminal paths

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Jinwoo-H
2026-05-31 02:26:10 -07:00
committed by Neil
co-authored by Orca
parent 6be0d6b275
commit a3195fa36f
3 changed files with 42 additions and 1 deletions
@@ -4,7 +4,9 @@ import { resolveTerminalFileUrlTarget } from './terminal-file-url-target'
describe('resolveTerminalFileUrlTarget', () => {
it('resolves UNC file URLs with line and column anchors', () => {
expect(
resolveTerminalFileUrlTarget(new URL('file://Server/Share/Repo/src/app.ts#L12C3'))
resolveTerminalFileUrlTarget(new URL('file://Server/Share/Repo/src/app.ts#L12C3'), {
allowUncHost: true
})
).toEqual({
filePath: '//server/Share/Repo/src/app.ts',
line: 12,
@@ -501,6 +501,38 @@ describe('handleOscLink', () => {
})
})
it('opens UNC file URL links with line and column anchors', async () => {
setPlatform('Windows')
handleOscLink(
'file://Server/Share/Repo/src/app.ts#L12C3',
{ metaKey: false, ctrlKey: true },
{
...deps,
worktreePath: '//Server/Share/Repo'
}
)
await flushAsyncWork()
await flushDoubleRaf()
expect(authorizeExternalPathMock).toHaveBeenCalledWith({
targetPath: '//server/Share/Repo/src/app.ts'
})
expect(openFileMock).toHaveBeenCalledWith(
expect.objectContaining({
filePath: '//server/Share/Repo/src/app.ts',
relativePath: 'src/app.ts'
})
)
expect(setPendingEditorRevealMock).toHaveBeenNthCalledWith(1, null)
expect(setPendingEditorRevealMock).toHaveBeenNthCalledWith(2, {
filePath: '//server/Share/Repo/src/app.ts',
line: 12,
column: 3,
matchLength: 0
})
})
it('opens relative OSC file links against the terminal cwd', async () => {
setPlatform('Macintosh')
@@ -20,6 +20,13 @@ describe('terminal path helpers', () => {
expect(
toWorktreeRelativePath('//server/share/repo/src/file.ts', '\\\\server\\share\\repo')
).toBe('src/file.ts')
expect(isPathInsideWorktree('//server/share/repo/src/file.ts', '//Server/Share/Repo')).toBe(
true
)
expect(toWorktreeRelativePath('//server/share/repo/src/file.ts', '//Server/Share/Repo')).toBe(
'src/file.ts'
)
})
describe('extractTerminalFileLinks bare-filename tokens', () => {