Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Second attempt at fixing msys terminal width. #6122

Merged
merged 1 commit into from
Oct 3, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/cargo/core/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,7 @@ mod imp {
mod imp {
extern crate winapi;

use std::mem;
use std::ptr;
use std::{cmp, mem, ptr};
use self::winapi::um::fileapi::*;
use self::winapi::um::handleapi::*;
use self::winapi::um::processenv::*;
Expand Down Expand Up @@ -395,13 +394,15 @@ mod imp {
CloseHandle(h);
if rc != 0 {
let width = (csbi.srWindow.Right - csbi.srWindow.Left) as usize;
// Some terminals, such as mintty, always return 79 instead of
// the actual width. In that case, use a conservative value.
if width == 79 {
return Some(60);
} else {
return Some(width);
}
// Unfortunately cygwin/mintty does not set the size of the
// backing console to match the actual window size. This
// always reports a size of 80 or 120 (not sure what
// determines that). Use a conservative max of 60 which should
// work in most circumstances. ConEmu does some magic to
// resize the console correctly, but there's no reasonable way
// to detect which kind of terminal we are running in, or if
// GetConsoleScreenBufferInfo returns accurate information.
return Some(cmp::min(60, width));
}
return None;
}
Expand Down