[CodeHealth] Convert useAutoSize to kwargs (#2259)

This commit is contained in:
Chenlei Hu
2025-01-15 17:06:45 -05:00
committed by GitHub
parent 184291d21b
commit 84b652a281
4 changed files with 21 additions and 11 deletions

View File

@@ -20,11 +20,16 @@ const terminalCreated = (
let offData: IDisposable
let offOutput: () => void
useAutoSize(root, true, true, () => {
// If we aren't visible, don't resize
if (!terminal.element?.offsetParent) return
useAutoSize({
root,
autoRows: true,
autoCols: true,
onResize: () => {
// If we aren't visible, don't resize
if (!terminal.element?.offsetParent) return
terminalApi.resize(terminal.cols, terminal.rows)
terminalApi.resize(terminal.cols, terminal.rows)
}
})
onMounted(async () => {

View File

@@ -29,7 +29,7 @@ const terminalCreated = (
{ terminal, useAutoSize }: ReturnType<typeof useTerminal>,
root: Ref<HTMLElement>
) => {
useAutoSize(root, true, false)
useAutoSize({ root, autoRows: true, autoCols: false })
const update = (entries: Array<LogEntry>, size?: TerminalSize) => {
if (size) {

View File

@@ -36,12 +36,17 @@ export function useTerminal(element: Ref<HTMLElement>) {
return {
terminal,
useAutoSize(
root: Ref<HTMLElement>,
autoRows: boolean = true,
autoCols: boolean = true,
useAutoSize({
root,
autoRows = true,
autoCols = true,
onResize
}: {
root: Ref<HTMLElement>
autoRows?: boolean
autoCols?: boolean
onResize?: () => void
) {
}) {
const ensureValidRows = (rows: number | undefined) => {
if (rows == null || isNaN(rows)) {
return root.value?.clientHeight / 20

View File

@@ -78,7 +78,7 @@ const terminalCreated = (
) => {
xterm = terminal
useAutoSize(root, true, true)
useAutoSize({ root, autoRows: true, autoCols: true })
electron.onLogMessage((message: string) => {
terminal.write(message)
})