diff options
author | A Farzat <a@farzat.xyz> | 2022-05-18 10:44:40 +0900 |
---|---|---|
committer | A Farzat <a@farzat.xyz> | 2022-05-18 10:44:40 +0900 |
commit | d9bbb2fad42f4652e418209686045897a8f61675 (patch) | |
tree | e8a7e14beaf042ef7652c74c633f529f5374a641 /edit.py | |
parent | 66ea1c1f3fe6602eee4233cd2ef10010a8a13f13 (diff) | |
download | edit-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.py | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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```" |