feat: filter IDE reference candidates
This commit is contained in:
@@ -63,4 +63,65 @@ describe('combineSnapshots', () => {
|
||||
expect(combineSnapshots([parsed], 'main', 1).items).toHaveLength(1)
|
||||
expect(combineSnapshots([parsed], 'main', 10).total).toBe(2)
|
||||
})
|
||||
|
||||
it('excludes Visual Studio project and solution files by default', () => {
|
||||
const parsed = parseSnapshot(snapshot('F:\\project\\main.cs', {
|
||||
documents: [
|
||||
{ path: 'F:\\project\\main.cs', label: 'main.cs', dirty: false },
|
||||
{ path: 'F:\\project\\app.csproj', label: 'app.csproj', dirty: false },
|
||||
{ path: 'F:\\project\\library.fsproj', label: 'library.fsproj', dirty: false },
|
||||
{ path: 'F:\\project\\tools.vbproj', label: 'tools.vbproj', dirty: false },
|
||||
{ path: 'F:\\project\\native.vcxproj', label: 'native.vcxproj', dirty: false },
|
||||
{ path: 'F:\\project\\legacy.vsproj', label: 'legacy.vsproj', dirty: false },
|
||||
{ path: 'F:\\project\\app.sln', label: 'app.sln', dirty: false },
|
||||
{ path: 'F:\\project\\app.slnx', label: 'app.slnx', dirty: false },
|
||||
],
|
||||
}), now)!
|
||||
|
||||
expect(combineSnapshots([parsed]).items.map((item) => item.label)).toEqual(['main.cs'])
|
||||
})
|
||||
|
||||
it('matches configured extensions without case sensitivity', () => {
|
||||
const parsed = parseSnapshot(snapshot('F:\\project\\main.cs', {
|
||||
documents: [
|
||||
{ path: 'F:\\project\\main.cs', label: 'main.cs', dirty: false },
|
||||
{ path: 'F:\\project\\APP.CSPROJ', label: 'APP.CSPROJ', dirty: false },
|
||||
],
|
||||
}), now)!
|
||||
|
||||
expect(combineSnapshots([parsed], '', 100, ['.csproj']).items.map((item) => item.label)).toEqual(['main.cs'])
|
||||
})
|
||||
|
||||
it('accepts configured extensions without a leading dot', () => {
|
||||
const parsed = parseSnapshot(snapshot('F:\\project\\main.cs', {
|
||||
documents: [
|
||||
{ path: 'F:\\project\\main.cs', label: 'main.cs', dirty: false },
|
||||
{ path: 'F:\\project\\app.slnx', label: 'app.slnx', dirty: false },
|
||||
],
|
||||
}), now)!
|
||||
|
||||
expect(combineSnapshots([parsed], '', 100, ['slnx']).items.map((item) => item.label)).toEqual(['main.cs'])
|
||||
})
|
||||
|
||||
it('disables filtering when excludedExtensions is empty', () => {
|
||||
const parsed = parseSnapshot(snapshot('F:\\project\\main.cs', {
|
||||
documents: [
|
||||
{ path: 'F:\\project\\main.cs', label: 'main.cs', dirty: false },
|
||||
{ path: 'F:\\project\\app.csproj', label: 'app.csproj', dirty: false },
|
||||
],
|
||||
}), now)!
|
||||
|
||||
expect(combineSnapshots([parsed], '', 100, []).total).toBe(2)
|
||||
})
|
||||
|
||||
it('reports the filtered document count for each instance', () => {
|
||||
const parsed = parseSnapshot(snapshot('F:\\project\\main.cs', {
|
||||
documents: [
|
||||
{ path: 'F:\\project\\main.cs', label: 'main.cs', dirty: false },
|
||||
{ path: 'F:\\project\\app.csproj', label: 'app.csproj', dirty: false },
|
||||
],
|
||||
}), now)!
|
||||
|
||||
expect(combineSnapshots([parsed]).items[0]?.instanceOpenCount).toBe(1)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -16,10 +16,7 @@ describe('client reference projection', () => {
|
||||
expect(serializeIdeReference(item.path)).toBe('<ide-open-file>{"path":"F:\\\\project\\\\a&b.ts"}</ide-open-file>')
|
||||
})
|
||||
|
||||
it('shows IDE, count and dirty state', () => {
|
||||
const candidate = candidateFromItem(item)
|
||||
expect(candidate.description).toContain('VS Code')
|
||||
expect(candidate.description).toContain('4 open')
|
||||
expect(candidate.description).toContain('unsaved changes')
|
||||
it('shows IDE, workspace, count and dirty state with ASCII separators', () => {
|
||||
expect(candidateFromItem(item).description).toBe('VS Code | F:\\project | 4 open | unsaved changes')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user