Fix TableView multi selections extending to -1 indexes (#1843)

* Fix TableView multi selections extending to -1 indexes

* Add to test confirmation that the main active cell also didn't get pushed off

* Tidy up formatting

* Fixed not calling Application.Shutdown in tests and made it easier to diagnose which test is not shutting down
This commit is contained in:
Thomas Nind
2022-06-27 17:09:31 +01:00
committed by GitHub
parent 8149eed9aa
commit 367fdd9bad
3 changed files with 116 additions and 5 deletions

View File

@@ -52,12 +52,27 @@ namespace Terminal.Gui.Views {
public class GraphViewTests {
static string LastInitFakeDriver;
public static FakeDriver InitFakeDriver ()
{
var driver = new FakeDriver ();
Application.Init (driver, new FakeMainLoop (() => FakeConsole.ReadKey (true)));
try {
Application.Init (driver, new FakeMainLoop (() => FakeConsole.ReadKey (true)));
} catch (InvalidOperationException) {
// close it so that we don't get a thousand of these errors in a row
Application.Shutdown ();
// but still report a failure and name the test that didn't shut down. Note
// that the test that didn't shutdown won't be the one currently running it will
// be the last one
throw new Exception ("A test did not call shutdown correctly. Test stack trace was:" + LastInitFakeDriver);
}
driver.Init (() => { });
LastInitFakeDriver = Environment.StackTrace;
return driver;
}