From 77511627e9ec3f047ad647aedf2c09b770dbe4cb Mon Sep 17 00:00:00 2001 From: Anonymous Date: Sat, 12 Feb 2022 20:26:09 -0800 Subject: [PATCH] LibLine: Fix loading of terminal dimensions when running under lldb --- Userland/Libraries/LibLine/Editor.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Userland/Libraries/LibLine/Editor.cpp b/Userland/Libraries/LibLine/Editor.cpp index 44b8884229..0c87ec4234 100644 --- a/Userland/Libraries/LibLine/Editor.cpp +++ b/Userland/Libraries/LibLine/Editor.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -222,6 +223,14 @@ void Editor::get_terminal_size() m_num_columns = 80; m_num_lines = 25; } else { + if (ws.ws_col == 0 || ws.ws_row == 0) { + // LLDB uses ttys which "work" and then gives us a zero sized + // terminal which is far from useful + if (int fd = open("/dev/tty", O_RDONLY); fd != -1) { + ioctl(fd, TIOCGWINSZ, &ws); + close (fd); + } + } m_num_columns = ws.ws_col; m_num_lines = ws.ws_row; }