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 <charles.milette@gmail.com>
This commit is contained in:
Cullen Ye 2024-04-14 21:31:38 -04:00 committed by GitHub
parent ed8f7f4eba
commit c7f8b9e97b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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"
return "Windows Terminal"