Browse Source

fix(windows): use terminal_size_of with borrowed raw handle

Signed-off-by: Christina Sørensen <christina@cafkafk.com>
Christina Sørensen 1 năm trước cách đây
mục cha
commit
0edfa4e7d1
1 tập tin đã thay đổi với 5 bổ sung2 xóa
  1. 5 2
      src/output/mod.rs

+ 5 - 2
src/output/mod.rs

@@ -65,9 +65,12 @@ impl TerminalWidth {
             { terminal_size::terminal_size_of(std::io::stdout()).map(|(w, _h)| w.0 as _) };
         #[cfg(windows)]
         let stdout_term_width = {
+            use std::os::windows::io::BorrowedHandle;
             use windows_sys::Win32::System::Console::{GetStdHandle, STD_OUTPUT_HANDLE};
-            terminal_size::terminal_size_using_handle(unsafe { GetStdHandle(STD_OUTPUT_HANDLE) })
-                .map(|(w, _h)| w.0 as _)
+            terminal_size::terminal_size_of(unsafe {
+                BorrowedHandle::borrow_raw(GetStdHandle(STD_OUTPUT_HANDLE))
+            })
+            .map(|(w, _h)| w.0 as _)
         };
 
         #[rustfmt::skip]