diff --git a/docs/changelog.rst b/docs/changelog.rst index 12fb70c28..356defc17 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -29,6 +29,10 @@ Changelog - icat kitten: Implement reading image data from STDIN, if STDIN is not connected to a terminal (:iss:`1130`) +- hints kitten: Insert trailing spaces after matches when using the + ``--multiple`` option. Also add a separate ``--add-traling-space`` + option to control this behavior (:pull:`1132`) + - Fix the ``*_with_cwd`` actions using the cwd of the overlay window rather than the underlying window's cwd (:iss:`1045`) diff --git a/kittens/hints/main.py b/kittens/hints/main.py index 7c60cecbd..f9f47534c 100644 --- a/kittens/hints/main.py +++ b/kittens/hints/main.py @@ -84,9 +84,17 @@ class Hints(Handler): self.args = args self.window_title = _('Choose URL') if args.type == 'url' else _('Choose text') self.multiple = args.multiple + self.match_suffix = self.get_match_suffix(args) self.chosen = [] self.reset() + def get_match_suffix(self, args): + if args.add_trailing_space == 'always': + return ' ' + if args.add_trailing_space == 'never': + return '' + return ' ' if args.multiple else '' + def reset(self): self.current_input = '' self.current_text = None @@ -112,7 +120,7 @@ class Hints(Handler): if encode_hint(idx).startswith(self.current_input) ] if len(matches) == 1: - self.chosen.append(matches[0].text) + self.chosen.append(matches[0].text + self.match_suffix) if self.multiple: self.ignore_mark_indices.add(matches[0].index) self.reset() @@ -130,7 +138,7 @@ class Hints(Handler): elif key_event is enter_key and self.current_input: try: idx = decode_hint(self.current_input) - self.chosen.append(self.index_map[idx].text) + self.chosen.append(self.index_map[idx].text + self.match_suffix) self.ignore_mark_indices.add(idx) except Exception: self.current_input = '' @@ -363,6 +371,13 @@ The minimum number of characters to consider a match. type=bool-set Select multiple matches and perform the action on all of them together at the end. In this mode, press :kbd:`Esc` to finish selecting. + + +--add-trailing-space +default=auto +choices=auto,always,never +Add trailing space after matched text. Defaults to auto, which adds the space +when used together with --multiple. '''.format(','.join(sorted(URL_PREFIXES))).format help_text = 'Select text from the screen using the keyboard. Defaults to searching for URLs.' usage = ''