✨ feat(vscode): 代码阅读侧栏跟着当前文件走,目录链接在侧栏树上定位
This commit is contained in:
1 parent
ff713db6e7
commit
c841ae678a
10 files changed
+464
-7
No files matched your search
@@ -0,0 +1,56 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { createExcludeMatcher } from './fileEntries'
|
||||
import { followsActiveFile, pathRelation, revealExcluded } from './treeReveal'
|
||||
|
||||
const file = (path: string): { scheme: string, authority: string, path: string } => ({ scheme: 'file', authority: '', path })
|
||||
|
||||
describe('树上一行和要找的路径的关系', () => {
|
||||
it('同一个路径是它自己', () => {
|
||||
expect(pathRelation(file('/ws/backend/a.py'), file('/ws/backend/a.py'))).toBe('self')
|
||||
})
|
||||
|
||||
it('上面任何一层目录都是往里找的那层', () => {
|
||||
expect(pathRelation(file('/ws'), file('/ws/backend/src/a.py'))).toBe('ancestor')
|
||||
expect(pathRelation(file('/ws/backend'), file('/ws/backend/src/a.py'))).toBe('ancestor')
|
||||
expect(pathRelation(file('/'), file('/ws/a.py'))).toBe('ancestor')
|
||||
})
|
||||
|
||||
it('名字开头相同的兄弟目录、下面的路径、别的协议都不相干', () => {
|
||||
expect(pathRelation(file('/ws/back'), file('/ws/backend/a.py'))).toBeUndefined()
|
||||
expect(pathRelation(file('/ws/backend/a.py'), file('/ws/backend'))).toBeUndefined()
|
||||
expect(pathRelation(file('/ws/other'), file('/ws/backend/a.py'))).toBeUndefined()
|
||||
expect(pathRelation({ scheme: 'git', authority: '', path: '/ws' }, file('/ws/a.py'))).toBeUndefined()
|
||||
expect(pathRelation({ scheme: 'file', authority: 'host', path: '/ws' }, file('/ws/a.py'))).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe('explorer.autoReveal 的几种值', () => {
|
||||
it('true 跟,false 不跟', () => {
|
||||
expect(followsActiveFile(true)).toBe(true)
|
||||
expect(followsActiveFile(false)).toBe(false)
|
||||
})
|
||||
|
||||
it('focusNoScroll 当作开着(插件的 reveal 选中就会滚过去)', () => {
|
||||
expect(followsActiveFile('focusNoScroll')).toBe(true)
|
||||
})
|
||||
|
||||
it('没读到时照 VS Code 的默认,开着', () => {
|
||||
expect(followsActiveFile(undefined)).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('explorer.autoRevealExclude', () => {
|
||||
const excluded = createExcludeMatcher({ '**/node_modules': true, '**/bower_components': true, 'build': false })
|
||||
|
||||
it('它自己或路上任何一层目录命中都不跟', () => {
|
||||
expect(revealExcluded(excluded, 'node_modules/react/index.js')).toBe(true)
|
||||
expect(revealExcluded(excluded, 'packages/web/node_modules/vue/dist/vue.js')).toBe(true)
|
||||
expect(revealExcluded(excluded, 'node_modules')).toBe(true)
|
||||
})
|
||||
|
||||
it('没命中、或那条关掉了的照跟', () => {
|
||||
expect(revealExcluded(excluded, 'backend/src/visibility.py')).toBe(false)
|
||||
expect(revealExcluded(excluded, 'build/out.js')).toBe(false)
|
||||
expect(revealExcluded(excluded, 'src/node_modules_helper.ts')).toBe(false)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user