aboutsummaryrefslogtreecommitdiff
path: root/edit.py
diff options
context:
space:
mode:
authorA Farzat <a@farzat.xyz>2022-05-18 10:44:40 +0900
committerA Farzat <a@farzat.xyz>2022-05-18 10:44:40 +0900
commitd9bbb2fad42f4652e418209686045897a8f61675 (patch)
treee8a7e14beaf042ef7652c74c633f529f5374a641 /edit.py
parent66ea1c1f3fe6602eee4233cd2ef10010a8a13f13 (diff)
downloadedit-d9bbb2fad42f4652e418209686045897a8f61675.tar.gz
edit-d9bbb2fad42f4652e418209686045897a8f61675.zip
Confirm text is not empty before checking newline
checking text[-1] when text is empty causes an error.
Diffstat (limited to 'edit.py')
-rw-r--r--edit.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/edit.py b/edit.py
index 5075ddc..bbabb7e 100644
--- a/edit.py
+++ b/edit.py
@@ -68,7 +68,7 @@ def read_file(buf):
with open(FILE) as f:
text = f.read()
- if text[-1] == "\n":
+ if text and text[-1] == "\n":
text = text[:-1] # remove trailing newline if exists.
if FENCED:
text = "```\n" + text + "\n```"