From c7f8b9e97bb7a709513ea651ba886401344860b8 Mon Sep 17 00:00:00 2001 From: Cullen Ye <59585764+CullenLYe@users.noreply.github.com> Date: Sun, 14 Apr 2024 21:31:38 -0400 Subject: [PATCH] Fixed bug: Clearing when there's no current terminal background no longer results in KeyError. (#211) * Fixed bug: Clearing when there's no current terminal background no longer causes a KeyError. Currently, if the user tries to input "pokemon -c" when there is no current terminal background, a KeyError is caused. I added a simple try/except block to print out "There's no current background to clear." to account for this. * Checking 'backgroundImage' directly * Removed try/except block * Update windowsterminal.py Simplify check --------- Co-authored-by: Charles Milette --- pokemonterminal/terminal/adapters/windowsterminal.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pokemonterminal/terminal/adapters/windowsterminal.py b/pokemonterminal/terminal/adapters/windowsterminal.py index 4784ff4..4fffce2 100644 --- a/pokemonterminal/terminal/adapters/windowsterminal.py +++ b/pokemonterminal/terminal/adapters/windowsterminal.py @@ -23,7 +23,7 @@ class WindowsTerminalProvider(_TProv): # update defaults profile profile = profiles['defaults'] - if (path is None): + if path is None and 'backgroundImage' in profile: del profile['backgroundImage'] else: profile['backgroundImage'] = path @@ -57,4 +57,4 @@ class WindowsTerminalProvider(_TProv): WindowsTerminalProvider.set_background_image(None) def __str__(): - return "Windows Terminal" \ No newline at end of file + return "Windows Terminal"