mirror of
https://github.com/stablyai/orca.git
synced 2026-10-20 08:03:28 +00:00
fix(mobile): detect files directly under path roots
This commit is contained in:
@@ -74,6 +74,21 @@ describe('detectFilePathSegments', () => {
|
||||
expect(detectFilePathSegments('/repo/src/index.ts')).toEqual([
|
||||
{ type: 'file', value: '/repo/src/index.ts', path: '/repo/src/index.ts' }
|
||||
])
|
||||
expect(detectFilePathSegments('/root.ts')).toEqual([
|
||||
{ type: 'file', value: '/root.ts', path: '/root.ts' }
|
||||
])
|
||||
})
|
||||
|
||||
it('detects files directly under explicit Windows and relative roots', () => {
|
||||
expect(detectFilePathSegments(String.raw`C:\root.ts`)).toEqual([
|
||||
{ type: 'file', value: String.raw`C:\root.ts`, path: String.raw`C:\root.ts` }
|
||||
])
|
||||
expect(detectFilePathSegments('./root.ts')).toEqual([
|
||||
{ type: 'file', value: './root.ts', path: 'root.ts' }
|
||||
])
|
||||
expect(detectFilePathSegments('../root.ts')).toEqual([
|
||||
{ type: 'file', value: '../root.ts', path: '../root.ts' }
|
||||
])
|
||||
})
|
||||
|
||||
it('detects paths with :line and :line:col suffixes', () => {
|
||||
|
||||
@@ -87,7 +87,7 @@ const EXTENSION_SET = new Set<string>(FILE_EXTENSIONS)
|
||||
// alternatives cover Windows drives, UNC, and POSIX absolute roots; the optional
|
||||
// tail captures agent-style :line(:col) citations.
|
||||
const CANDIDATE_PATTERN =
|
||||
/(?:[A-Za-z]:[\\/]|\\\\|[\\/])?(?:\.{1,2}[\\/])?(?:[\w.@~+-]+[\\/])+[\w.@+-]+\.[A-Za-z0-9]+(?::[1-9]\d*(?::[1-9]\d*)?)?/g
|
||||
/(?:(?:[A-Za-z]:[\\/]|\\\\|[\\/]|\.{1,2}[\\/])(?:[\w.@~+-]+[\\/])*|(?:[\w.@~+-]+[\\/])+)[\w.@+-]+\.[A-Za-z0-9]+(?::[1-9]\d*(?::[1-9]\d*)?)?/g
|
||||
|
||||
// A path candidate in chat prose is short; a much longer run can't hold one worth
|
||||
// linkifying but can push CANDIDATE_PATTERN into super-linear backtracking, so we
|
||||
|
||||
Reference in New Issue
Block a user