aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2024-11-17 23:02:08 +1300
committerTom Ryder <tom@sanctum.geek.nz>2024-11-17 23:02:08 +1300
commitffb444f1e7269115308cb78147561adc67faebc2 (patch)
tree371c12919d248554f2ba6d306f863785c7f10274
parentAdd system config file (diff)
downloadvixf-ffb444f1e7269115308cb78147561adc67faebc2.tar.gz
vixf-ffb444f1e7269115308cb78147561adc67faebc2.zip
Treat empty temp file as an error condition
-rw-r--r--vixf.py313
1 files changed, 8 insertions, 5 deletions
diff --git a/vixf.py3 b/vixf.py3
index 828d3db..2e0adb2 100644
--- a/vixf.py3
+++ b/vixf.py3
@@ -99,15 +99,18 @@ def main(environ):
# If any data in the file after edit, copy it to the clipboard
if len(content_after):
pyperclip.copy(content_after)
+ else:
+ print(
+ f'{SELF}: Nothing to paste. Did the edit work?',
+ file=sys.stderr,
+ )
+ sys.exit(1)
focus_delay(config)
- # If we had content, paste it; if we didn't, cut what was there
+ # Paste modified content
with keyboard.pressed(pynput.keyboard.Key.ctrl):
- if len(content_after):
- keyboard.type('v')
- else:
- keyboard.type('x')
+ keyboard.type('v')
def focus_delay(config):