summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2017-11-05 17:20:13 +0000
committerPatrick Totzke <patricktotzke@gmail.com>2017-11-05 17:38:06 +0000
commit87225c353689f226fe0128b84ee60dd138c1bba2 (patch)
tree577df0090306e2de730b6283bd916d519ef499ce /alot
parentcceec453ae54b19606a7e4ad743ff13f750e57f8 (diff)
keep ThreadBuffer indentation non-negative
this makes sure that 'tbuffer._indent_width', which stores the requested indentation width, remains non-negative. As a consequence, multiple "decrease" operations on zero values can be reverted by a single "increase", as is intuitive.
Diffstat (limited to 'alot')
-rw-r--r--alot/commands/thread.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/alot/commands/thread.py b/alot/commands/thread.py
index 33230197..700149d9 100644
--- a/alot/commands/thread.py
+++ b/alot/commands/thread.py
@@ -573,12 +573,14 @@ class ChangeDisplaymodeCommand(Command):
# set message/reply indentation if changed
if self.indent is not None:
if self.indent == '+':
- tbuffer._indent_width += 1
+ newindent = tbuffer._indent_width + 1
elif self.indent == '-':
- tbuffer._indent_width -= 1
+ newindent = tbuffer._indent_width - 1
else:
# argparse validation guarantees that self.indent is an integer
- tbuffer._indent_width = self.indent
+ newindent = self.indent
+ # make sure indent remains non-negative
+ tbuffer._indent_width = max(newindent, 0)
tbuffer.rebuild()
tbuffer.collapse_all()
ui.update()