aboutsummaryrefslogtreecommitdiff
path: root/edit.py
diff options
context:
space:
mode:
authorA Farzat <a@farzat.xyz>2022-05-14 15:55:43 +0900
committerA Farzat <a@farzat.xyz>2022-05-14 15:55:43 +0900
commit257ae01ffcec943804989ff24e73dceec2fea654 (patch)
treeb49302efe017ad761acd666e11970c51a98ad583 /edit.py
parentc1f6966d32f8c54a480fa60b20eb9e82c4a16a33 (diff)
downloadedit-257ae01ffcec943804989ff24e73dceec2fea654.tar.gz
edit-257ae01ffcec943804989ff24e73dceec2fea654.zip
Remove trailing newline character if exists
Diffstat (limited to 'edit.py')
-rw-r--r--edit.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/edit.py b/edit.py
index ca6ab3f..503bc6f 100644
--- a/edit.py
+++ b/edit.py
@@ -60,6 +60,9 @@ def read_file(path, buf):
with open(PATH) as f:
text = f.read()
+ if text[-1] == "\n":
+ text = text[:-1] # remove trailing newline if exists.
+
weechat.buffer_set(buf, "input", text)
weechat.buffer_set(buf, "input_pos", str(len(text)))