From d15f2823f3431165f45f2ed6eadcf62a931cdcf5 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 7 Jan 2020 09:49:32 +0000 Subject: winansi: restore correct attributes after ls As reported in GitHub issue #178 the last colour set by the ls command is retained in the console. This is due to the previous commit reinitialising the stored attributes more frequently than it should. Attriubutes should only be initialised once. --- win32/winansi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/win32/winansi.c b/win32/winansi.c index f45970747..0d8cf662a 100644 --- a/win32/winansi.c +++ b/win32/winansi.c @@ -32,9 +32,15 @@ static HANDLE get_console(void) static void init(void) { - HANDLE console = get_console(); + static int initialised = FALSE; + HANDLE console; CONSOLE_SCREEN_BUFFER_INFO sbi; + if (initialised) + return; + initialised = TRUE; + + console = get_console(); if (GetConsoleScreenBufferInfo(console, &sbi)) { attr = plain_attr = sbi.wAttributes; negative = 0; -- cgit v1.2.3-55-g6feb