mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-30 22:54:14 +00:00 
			
		
		
		
	#324 Remove arrows in case there is only one match
This commit is contained in:
		| @@ -92,6 +92,13 @@ class TestSelectCommand(object): | |||||||
|                                       require_confirmation=True)) == commands[0] |                                       require_confirmation=True)) == commands[0] | ||||||
|         assert capsys.readouterr() == ('', u'\x1b[1K\rls [enter/↑/↓/ctrl+c]\n') |         assert capsys.readouterr() == ('', u'\x1b[1K\rls [enter/↑/↓/ctrl+c]\n') | ||||||
|  |  | ||||||
|  |     def test_with_confirmation_one_match(self, capsys, patch_getch, commands): | ||||||
|  |         patch_getch(['\n']) | ||||||
|  |         assert ui.select_command((commands[0],), | ||||||
|  |                                  Mock(debug=False, no_color=True, | ||||||
|  |                                       require_confirmation=True)) == commands[0] | ||||||
|  |         assert capsys.readouterr() == ('', u'\x1b[1K\rls [enter/ctrl+c]\n') | ||||||
|  |  | ||||||
|     def test_with_confirmation_abort(self, capsys, patch_getch, commands): |     def test_with_confirmation_abort(self, capsys, patch_getch, commands): | ||||||
|         patch_getch([KeyboardInterrupt]) |         patch_getch([KeyboardInterrupt]) | ||||||
|         assert ui.select_command(commands, |         assert ui.select_command(commands, | ||||||
|   | |||||||
| @@ -45,12 +45,18 @@ def show_corrected_command(corrected_command, settings): | |||||||
|         reset=color(colorama.Style.RESET_ALL, settings))) |         reset=color(colorama.Style.RESET_ALL, settings))) | ||||||
|  |  | ||||||
|  |  | ||||||
| def confirm_text(corrected_command, settings): | def confirm_text(corrected_command, multiple_cmds, settings): | ||||||
|  |     if multiple_cmds: | ||||||
|  |         arrows = '{blue}↑{reset}/{blue}↓{reset}/' | ||||||
|  |     else: | ||||||
|  |         arrows = '' | ||||||
|  |  | ||||||
|     sys.stderr.write( |     sys.stderr.write( | ||||||
|         '\033[1K\r{bold}{script}{reset}{side_effect} ' |         ('{clear}{bold}{script}{reset}{side_effect} ' | ||||||
|         '[{green}enter{reset}/{blue}↑{reset}/{blue}↓{reset}/{red}ctrl+c{reset}]'.format( |          '[{green}enter{reset}/' + arrows + '{red}ctrl+c{reset}]').format( | ||||||
|             script=corrected_command.script, |             script=corrected_command.script, | ||||||
|             side_effect=' (+side effect)' if corrected_command.side_effect else '', |             side_effect=' (+side effect)' if corrected_command.side_effect else '', | ||||||
|  |             clear='\033[1K\r', | ||||||
|             bold=color(colorama.Style.BRIGHT, settings), |             bold=color(colorama.Style.BRIGHT, settings), | ||||||
|             green=color(colorama.Fore.GREEN, settings), |             green=color(colorama.Fore.GREEN, settings), | ||||||
|             red=color(colorama.Fore.RED, settings), |             red=color(colorama.Fore.RED, settings), | ||||||
|   | |||||||
| @@ -44,8 +44,7 @@ def read_actions(): | |||||||
|  |  | ||||||
|         if buffer == ['\x1b', '[', 'A']:  # ↑ |         if buffer == ['\x1b', '[', 'A']:  # ↑ | ||||||
|             yield PREVIOUS |             yield PREVIOUS | ||||||
|  |         elif buffer == ['\x1b', '[', 'B']:  # ↓ | ||||||
|         if buffer == ['\x1b', '[', 'B']:  # ↓ |  | ||||||
|             yield NEXT |             yield NEXT | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -89,7 +88,9 @@ def select_command(corrected_commands, settings): | |||||||
|         logs.show_corrected_command(selector.value, settings) |         logs.show_corrected_command(selector.value, settings) | ||||||
|         return selector.value |         return selector.value | ||||||
|  |  | ||||||
|     selector.on_change(lambda val: logs.confirm_text(val, settings)) |     multiple_cmds = len(corrected_commands) > 1 | ||||||
|  |  | ||||||
|  |     selector.on_change(lambda val: logs.confirm_text(val, multiple_cmds, settings)) | ||||||
|     for action in read_actions(): |     for action in read_actions(): | ||||||
|         if action == SELECT: |         if action == SELECT: | ||||||
|             sys.stderr.write('\n') |             sys.stderr.write('\n') | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user