MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / computeInputLayoutMetrics

Function computeInputLayoutMetrics

cli/src/utils/text-layout.ts:113–149  ·  view source on GitHub ↗
({
  layoutContent,
  cursorProbe,
  cols,
  maxHeight,
  minHeight = 1,
}: {
  layoutContent: string
  cursorProbe: string
  cols: number
  maxHeight: number
  minHeight?: number
})

Source from the content-addressed store, hash-verified

111}
112
113export function computeInputLayoutMetrics({
114 layoutContent,
115 cursorProbe,
116 cols,
117 maxHeight,
118 minHeight = 1,
119}: {
120 layoutContent: string
121 cursorProbe: string
122 cols: number
123 maxHeight: number
124 minHeight?: number
125}): { heightLines: number; gutterEnabled: boolean } {
126 const safeMaxHeight = Math.max(1, maxHeight)
127 const effectiveMinHeight = Math.max(
128 1,
129 Math.min(minHeight ?? 1, safeMaxHeight),
130 )
131 const totalLines = measureLines(layoutContent, cols)
132 const cursorLines = measureLines(cursorProbe, cols)
133
134 // Add bottom gutter when cursor is on line 2 of exactly 2 lines
135 const gutterEnabled =
136 totalLines === 2 && cursorLines === 2 && totalLines + 1 <= safeMaxHeight
137
138 const rawHeight = Math.min(
139 totalLines + (gutterEnabled ? 1 : 0),
140 safeMaxHeight,
141 )
142
143 const heightLines = Math.max(effectiveMinHeight, rawHeight)
144
145 return {
146 heightLines,
147 gutterEnabled,
148 }
149}

Callers 2

ChatFunction · 0.90

Calls 1

measureLinesFunction · 0.85

Tested by

no test coverage detected