Skip to content

Commit

Permalink
Accept blank string for autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
deanishe committed Dec 22, 2014
1 parent 0c1590a commit 7833cf0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion workflow/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,28 +734,39 @@ def elem(self):
"""

# Attributes on <item> element
attr = {}
if self.valid:
attr['valid'] = 'yes'
else:
attr['valid'] = 'no'
# Allow empty string for autocomplete. This is a useful value,
# as TABing the result will revert the query back to just the
# keyword
if self.autocomplete is not None:
attr['autocomplete'] = self.autocomplete

# Optional attributes
for name in ('uid', 'type', 'autocomplete'):
for name in ('uid', 'type'):
value = getattr(self, name, None)
if value:
attr[name] = value

root = ET.Element('item', attr)
ET.SubElement(root, 'title').text = self.title
ET.SubElement(root, 'subtitle').text = self.subtitle

# Add modifier subtitles
for mod in ('cmd', 'ctrl', 'alt', 'shift', 'fn'):
if mod in self.modifier_subtitles:
ET.SubElement(root, 'subtitle',
{'mod': mod}).text = self.modifier_subtitles[mod]

# Add arg as element instead of attribute on <item>, as it's more
# flexible (newlines aren't allowed in attributes)
if self.arg:
ET.SubElement(root, 'arg').text = self.arg

# Add icon if there is one
if self.icon:
if self.icontype:
Expand Down

0 comments on commit 7833cf0

Please sign in to comment.