From b9da5d1cbb1c43d6daee77a64b99b84904d7111a Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sun, 23 Dec 2018 09:12:28 -0800 Subject: [PATCH] Added guard clause to saving script. To prevent crash at return key on empty save dialog --- chalk | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/chalk b/chalk index b527ed9..748ada2 100755 --- a/chalk +++ b/chalk @@ -180,8 +180,6 @@ def chalk(path): elif re.match(r'^\!\d+$',ln): try: row = int(ln[1:]) - # print('{:8} {}Type !c to cancel line edit{}'.format(' ', c.yellow, c.end)) - # print('{:>6} : {}'.format('old', content[row])) newln = input_editable('{:6} {}>{} '.format(row, c.b_blue, c.end), content[row]) if newln == '!c': print('{:8} Cancelled...'.format(' ')) @@ -197,6 +195,10 @@ def chalk(path): confirmation = '' while confirmation.lower() not in ['y','yes','n','no']: confirmation = input('{}Save {}?{} (Y/n) '.format(c.b_green, fn, c.end)) + + if not len(confirmation): + continue + if confirmation.lower()[0] == 'y': print('{}saving...{}'.format(c.white, c.end)) text = '\n'.join(content)