fsharp/fsharp — pull request #342 by soimort (2014-10-28 13:15:01+00:00)
Title: Set boundary for Console.CursorTop (fix #168)

This workaround fixes a long-running bug in `fsharpi` on Linux / Unix, which annoyed me for a while, as previously reported in #168 and #13 (and possibly [this one](https://bugzilla.xamarin.com/show_bug.cgi?id=9814) on Xamarin's issue tracker), i.e. whenever a terminal window is resized and shrinked vertically, an exception `Value must be positive and below the buffer height.` is thrown.

By setting a boundary for `CursorTop`, it is ensured that its value [can never exceed](https://github.com/mono/mono/blob/master/mcs/class/corlib/System/TermInfoDriver.cs#L1225) `BufferHeight`. Once the terminal is shrinked, the cursor always appears on the bottom of the buffer.

(I'm not really sure if this one belongs here or https://visualfsharp.codeplex.com, as one may not dynamically adjust the buffer size on a Windows console so easily. Might not be too relevant for Windows users, but let me know if I should send it there.)