diff options
author | Enan Ajmain <3nan.ajmain@gmail.com> | 2023-01-23 15:45:18 +0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-23 01:45:18 -0800 |
commit | b36b58d0d4869b573ca6657db0d43eed2cbdd72f (patch) | |
tree | 33174f8dd73d07ba256a1de4ff547581febfdf77 | |
parent | cb757f2663e6950e655c6306d713338dfa66b18d (diff) | |
download | rneovim-b36b58d0d4869b573ca6657db0d43eed2cbdd72f.tar.gz rneovim-b36b58d0d4869b573ca6657db0d43eed2cbdd72f.tar.bz2 rneovim-b36b58d0d4869b573ca6657db0d43eed2cbdd72f.zip |
fix(Windows): restore console title at exit #21922
Fixes #21404
-rw-r--r-- | src/nvim/main.c | 2 | ||||
-rw-r--r-- | src/nvim/os/os_win_console.c | 13 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/nvim/main.c b/src/nvim/main.c index c3f6b6788e..bbe877356d 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -584,6 +584,7 @@ int main(int argc, char **argv) if (use_builtin_ui) { os_icon_init(); } + os_title_save(); #endif // Adjust default register name for "unnamed" in 'clipboard'. Can only be @@ -775,6 +776,7 @@ void getout(int exitval) #ifdef MSWIN // Restore Windows console icon before exiting. os_icon_set(NULL, NULL); + os_title_reset(); #endif os_exit(exitval); diff --git a/src/nvim/os/os_win_console.c b/src/nvim/os/os_win_console.c index 18f6e8b37b..006e27d28f 100644 --- a/src/nvim/os/os_win_console.c +++ b/src/nvim/os/os_win_console.c @@ -10,6 +10,7 @@ # include "os/os_win_console.c.generated.h" #endif +static char origTitle[256] = { 0 }; static HWND hWnd = NULL; static HICON hOrigIconSmall = NULL; static HICON hOrigIcon = NULL; @@ -92,3 +93,15 @@ void os_icon_init(void) } } } + +/// Saves the original Windows console title. +void os_title_save(void) +{ + GetConsoleTitle(origTitle, sizeof(origTitle)); +} + +/// Resets the original Windows console title. +void os_title_reset(void) +{ + SetConsoleTitle(origTitle); +} |