diff --git a/src/renderer/src/components/terminal-pane/terminal-file-url-target.test.ts b/src/renderer/src/components/terminal-pane/terminal-file-url-target.test.ts index 6927767c1c7..1b66ba2748e 100644 --- a/src/renderer/src/components/terminal-pane/terminal-file-url-target.test.ts +++ b/src/renderer/src/components/terminal-pane/terminal-file-url-target.test.ts @@ -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, diff --git a/src/renderer/src/components/terminal-pane/terminal-link-handlers.test.ts b/src/renderer/src/components/terminal-pane/terminal-link-handlers.test.ts index 932d80f02ef..73e1227e9d2 100644 --- a/src/renderer/src/components/terminal-pane/terminal-link-handlers.test.ts +++ b/src/renderer/src/components/terminal-pane/terminal-link-handlers.test.ts @@ -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') diff --git a/src/renderer/src/lib/terminal-links.test.ts b/src/renderer/src/lib/terminal-links.test.ts index a1d590e3233..897bac5d472 100644 --- a/src/renderer/src/lib/terminal-links.test.ts +++ b/src/renderer/src/lib/terminal-links.test.ts @@ -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', () => {