✨ feat(vscode): 代码阅读函数块默认折叠,函数说明进属性表「说明」行
This commit is contained in:
1 parent
62f48fe67c
commit
9b32d4b5a8
17 files changed
+489
-100
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { toBlockViews } from './blockView'
|
||||
import { blockReplacement, commonIndent, reindentBlock, replaceLines } from './editText'
|
||||
import { createPythonAdapter } from './languages/python'
|
||||
import { createTypeScriptAdapter } from './languages/typescript'
|
||||
import { readFixture, WASM_DIR, withBlocks } from './testSupport'
|
||||
|
||||
@@ -33,10 +34,14 @@ describe('行替换', () => {
|
||||
expect(reindentBlock([' x'], 'a\n b')).toBe(' a\n b')
|
||||
})
|
||||
|
||||
it('把预览里的 code 原样写回,文件不变(去缩进与补缩进互逆)', async () => {
|
||||
const adapter = createTypeScriptAdapter(WASM_DIR)
|
||||
const source = readFixture('envLock.ts.txt')
|
||||
const views = await withBlocks(adapter, 'typescript', source, blocks => toBlockViews(blocks, source, adapter, undefined))
|
||||
it.each([
|
||||
[createTypeScriptAdapter(WASM_DIR), 'typescript', 'envLock.ts.txt'],
|
||||
[createTypeScriptAdapter(WASM_DIR), 'typescript', 'issueLock.ts.txt'],
|
||||
[createPythonAdapter(WASM_DIR), 'python', 'sample.py'],
|
||||
[createPythonAdapter(WASM_DIR), 'python', 'routes.py'],
|
||||
] as const)('%#: 把预览里的 code 原样写回,文件不变(去缩进与补缩进互逆,函数头部连着说明也一样)', async (adapter, languageId, fixture) => {
|
||||
const source = readFixture(fixture)
|
||||
const views = await withBlocks(adapter, languageId, source, blocks => toBlockViews(blocks, source, adapter, undefined))
|
||||
const all = views.flatMap(function flat(view): typeof views {
|
||||
return [view, ...view.children.flatMap(flat)]
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user