Project

General

Profile

Actions

Bug #13888

closed

Consistent error in IO::Console.winsize=

Added by jm_beauvais (Jean-Michel Beauvais) over 7 years ago. Updated over 7 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.1p111 (2017-03-22 revision 58053) [x64-mingw32]
[ruby-core:82741]

Description

When trying to change the console window size, an error is always thrown, but the column size gets changed if the new value is higher than old value.
This behaviour can be observed by running the following code :

require 'io/console'

rows, cols = IO::console.winsize
puts "START : r = #{rows}, c = #{cols}", '* INCREASE COLUMNS BY 1', nil
arr = rows, cols+1
# 4 args same error
#arr = rows, cols+1, 0, 0

begin
	IO::console.winsize = arr
rescue Errno::EINVAL
	puts 'Predicted error...', $!
end

rows, cols = IO::console.winsize
puts nil, " STEP : r = #{rows}, c = #{cols}", '* DECREASE COLUMNS BY 1', nil # Column size has increased even if an error was raised.
arr = rows, cols-1
#arr = rows, cols-1, 0, 0

begin
	IO::console.winsize = arr
rescue Errno::EINVAL
	puts 'Predicted error...', $!
end

rows, cols = IO::console.winsize
puts nil, "  END : r = #{rows}, c = #{cols}" # Column size was not decreased.
gets

Which returns :


START : r = 25, c = 80
* INCREASE COLUMNS BY 1

Predicted error...
Invalid argument - SetConsoleWindowInfo

 STEP : r = 25, c = 81
* DECREASE COLUMNS BY 1

Predicted error...
Invalid argument - SetConsoleWindowInfo

  END : r = 25, c = 81

This was observed on a Windows 7 x64 computer (all important updates installed up to 2017-09-10).

Actions #1

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r59844.


console.c: set winsize on Windows

  • ext/io/console/console.c (console_set_winsize): retry shrinking
    window and screen buffer. [ruby-core:82741] [Bug #13888]
Actions

Also available in: Atom PDF

Like0
Like0