Skip to content

Commit add6eac

Browse files
fix(mobile): keep the Android terminal grid check under detekt's complexity limit
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 6404004 commit add6eac

1 file changed

Lines changed: 7 additions & 16 deletions

File tree

  • apps/mobile/modules/t3-terminal/android/src/main/java/expo/modules/t3terminal

‎apps/mobile/modules/t3-terminal/android/src/main/java/expo/modules/t3terminal/T3TerminalView.kt‎

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ class T3TerminalView(context: Context, appContext: AppContext) : ExpoView(contex
6767
private var streamedOutput: TerminalOutputBuffer? = null
6868
private var cols = 0
6969
private var rows = 0
70-
private var cellWidth = 0
71-
private var cellHeight = 0
70+
private var cellSize = 0 to 0
7271
private var measuredCols = 0
7372
private var measuredRows = 0
7473
private var clearingInput = false
@@ -364,26 +363,18 @@ class T3TerminalView(context: Context, appContext: AppContext) : ExpoView(contex
364363
val shared = sharedGrid.takeIf { it.size == 2 && it[0] > 0 && it[1] > 0 }
365364
val nextCols = shared?.get(0)?.coerceAtMost(measuredCols) ?: measuredCols
366365
val nextRows = shared?.get(1)?.coerceAtMost(measuredRows) ?: measuredRows
367-
val nextCellWidth = terminalCanvas.cellWidthPx.toInt()
368-
val nextCellHeight = terminalCanvas.cellHeightPx.toInt()
369-
if (
370-
nextCols == cols &&
371-
nextRows == rows &&
372-
nextCellWidth == cellWidth &&
373-
nextCellHeight == cellHeight &&
374-
terminalHandle != 0L
375-
) {
366+
val nextCellSize = terminalCanvas.cellWidthPx.toInt() to terminalCanvas.cellHeightPx.toInt()
367+
if (nextCols == cols && nextRows == rows && nextCellSize == cellSize && terminalHandle != 0L) {
376368
return
377369
}
378370
cols = nextCols
379371
rows = nextRows
380-
cellWidth = nextCellWidth
381-
cellHeight = nextCellHeight
372+
cellSize = nextCellSize
382373
val response = if (terminalHandle == 0L) {
383374
createTerminal()
384375
ByteArray(0)
385376
} else {
386-
GhosttyBridge.nativeResize(terminalHandle, cols, rows, cellWidth, cellHeight)
377+
GhosttyBridge.nativeResize(terminalHandle, cols, rows, cellSize.first, cellSize.second)
387378
}
388379
emitResponse(response)
389380
if (!hasPendingBuffer) feedPendingBuffer()
@@ -396,8 +387,8 @@ class T3TerminalView(context: Context, appContext: AppContext) : ExpoView(contex
396387
terminalHandle = GhosttyBridge.nativeCreate(
397388
cols,
398389
rows,
399-
cellWidth,
400-
cellHeight,
390+
cellSize.first,
391+
cellSize.second,
401392
foregroundColorValue,
402393
backgroundColorValue,
403394
cursorColorValue,

0 commit comments

Comments
 (0)