✨ feat(vscode): 代码阅读的调用嵌套:实参的值又是跨多行的调用时在值那一格里写它的一行、套它的实参表,一层层往下套;埋在式子里后面还跟着东西的调用括起来

This commit is contained in:
cruldra committed 2026-09-27 22:31:35 +08:00
1 parent dc100692b3
commit 285d711740
16 files changed
+471 -55

No files matched your search

@@ -6,7 +6,7 @@ import { inlineText } from './segments'
import { SegmentText } from './SegmentText'
import { subRowsLayout, tableCells, tableTemplate } from './subRows'
import { TextPreview } from './TextPreview'
import { propertyItemId, propertyRowId } from './viewState'
import { propertyItemId, propertyRowId, tableId } from './viewState'
/** 列表子行里除最后一列以外各列的宽度(字典的键),最后一列占满剩下的;编辑区窄时按比例收,不把最后一列挤没 */
const CELL_WIDTHS = ['min(150px, 28%)', 'min(220px, 38%)']
@@ -96,7 +96,8 @@ function PropertyItems({ parentId, items, folding }: { parentId: string, items:
/**
* 给了列名的子行(输入参数、数据表的字段)排成表格:第一行是表头(列名),下面每个子行一行;外框圆角,格子之间、行之间一条分隔线。
* 列宽按整列的内容定(见 tableTemplate),最后一列分剩下的,长了在格子里换行。一行译文下面摊开实参的表也用它。
* 列宽按整列的内容定(见 tableTemplate),最后一列分剩下的,长了在格子里换行。一行译文下面摊开实参的表也用它;
* 行带 table(实参的值里跨几行写的调用)时,那张表排在最后一格里、文字下面,往右缩一点,一层层往下套。
*/
export function PropertyTable({ parentId, columns, items }: { parentId: string, columns: string[], items: PropertyItem[] }): ReactElement {
return (
@@ -105,15 +106,28 @@ export function PropertyTable({ parentId, columns, items }: { parentId: string,
<div className="cr-table-head" role="row">
{columns.map((name, i) => <span key={i} className="cr-table-cell" role="columnheader">{name}</span>)}
</div>
{items.map((item, index) => (
<div key={index} className="cr-table-row" role="row" data-id={propertyItemId(parentId, index)}>
{tableCells(item, columns).map((cell, i) => (
<p key={i} className="cr-table-cell cr-code min-w-0" role="cell">
<SegmentText segments={cell} />
</p>
))}
</div>
))}
{items.map((item, index) => {
const id = propertyItemId(parentId, index)
const cells = tableCells(item, columns)
return (
<div key={index} className="cr-table-row" role="row" data-id={id}>
{cells.map((cell, i) => item.table && i === cells.length - 1
? (
<div key={i} className="cr-table-cell flex min-w-0 flex-col gap-[3px]" role="cell">
<p className="cr-code">
<SegmentText segments={cell} />
</p>
<PropertyTable parentId={tableId(id)} columns={item.table.columns} items={item.table.items} />
</div>
)
: (
<p key={i} className="cr-table-cell cr-code min-w-0" role="cell">
<SegmentText segments={cell} />
</p>
))}
</div>
)
})}
</div>
</div>
)