Skip to content

Commit

Permalink
Fix issue with single-line phrases with a newline (e.g. a shell comma…
Browse files Browse the repository at this point in the history
…nd). Resolves #48.
  • Loading branch information
bostrt committed Nov 28, 2020
1 parent 64f381e commit 7849ca8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions quikey/quikey.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import subprocess

MARKER = '''
# Everything after this line will be ignored.
# Everything below this line will be ignored.
# Insert your quikey phrase into this file then save and close.
'''

Expand Down Expand Up @@ -55,9 +55,9 @@ def add(ctx,name,phrase,tag):
if phrase is not None:
contents = phrase
else:
contents = click.edit('\n\n'+MARKER)
contents = click.edit(MARKER)
if contents is not None:
contents = contents.split(MARKER, 1)[0].rstrip('\n')
contents = contents.split(MARKER, 1)[0]
else:
click.echo('quikey phrase with key of %s not added' % name)
return
Expand All @@ -78,9 +78,9 @@ def edit(ctx,name):

phrase = db.get(name)
if phrase is not None:
contents = click.edit(phrase + '\n\n' + MARKER)
contents = click.edit(phrase + MARKER)
if contents is not None:
contents = contents.split(MARKER, 1)[0].rstrip('\n')
contents = contents.split(MARKER, 1)[0]
db.update(name, contents)
click.echo('quikey phrase with key of %s updated.' % name)
else:
Expand Down Expand Up @@ -145,7 +145,7 @@ def keyimport(ctx,location):
else:
contents = click.edit('\n\n'+MARKER)
if contents is not None:
contents = contents.split(MARKER, 1)[0].rstrip('\n')
contents = contents.split(MARKER, 1)[0]
else:
click.echo('quikey phrase with key of %s not added' % key)
continue
Expand Down

0 comments on commit 7849ca8

Please sign in to comment.