Skip to content

Commit 07b097d

Browse files
committed
fix: Redraw complete hint in original position
1 parent 8856bb9 commit 07b097d

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

easymotion.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ def setup_logging():
4141
logging.getLogger().disabled = True
4242
return
4343

44-
log_file = os.path.expanduser(
45-
'~/easymotion.log' if debug_mode else '~/easymotion_performance.log')
44+
log_file = os.path.expanduser( '~/easymotion.log')
4645
logging.basicConfig(
4746
filename=log_file,
4847
level=logging.DEBUG,
@@ -396,14 +395,13 @@ def draw_all_hints(panes, terminal_height):
396395
for line_num, col, char, hint in pane.positions:
397396
y = pane.start_y + line_num
398397
x = pane.start_x + col
399-
if (y < min(pane.start_y + pane.height, terminal_height) and
400-
x < pane.start_x + pane.width and
401-
x + get_char_width(char) + 1 < pane.start_x + pane.width):
398+
if (y < min(pane.start_y + pane.height, terminal_height) and x + get_char_width(char) <= pane.start_x + pane.width):
402399
sys.stdout.write(
403400
f'{ESC}[{y + 1};{x + 1}H{RED_FG}{hint[0]}{RESET}')
404401
char_width = get_char_width(char)
405-
sys.stdout.write(
406-
f'{ESC}[{y + 1};{x + char_width + 1}H{GREEN_FG}{hint[1]}{RESET}')
402+
if x + char_width < pane.start_x + pane.width:
403+
sys.stdout.write(
404+
f'{ESC}[{y + 1};{x + char_width + 1}H{GREEN_FG}{hint[1]}{RESET}')
407405
sys.stdout.flush()
408406

409407

@@ -442,11 +440,12 @@ def main():
442440
y = pane.start_y + line_num
443441
x = pane.start_x + col
444442
char_width = get_char_width(char)
445-
if (y < min(pane.start_y + pane.height, terminal_height) and
446-
x < pane.start_x + pane.width and
447-
x + char_width + 1 < pane.start_x + pane.width):
448-
sys.stdout.write(
449-
f'{ESC}[{y + 1};{x + char_width + 1}H{GREEN_FG}{hint[1]}{RESET}')
443+
if (y < min(pane.start_y + pane.height, terminal_height) and x + char_width <= pane.start_x + pane.width):
444+
# Clear first position and show second character
445+
sys.stdout.write(f'{ESC}[{y + 1};{x + 1}H{GREEN_FG}{hint[1]}{RESET}')
446+
# Restore original character in second position (if there's space)
447+
if x + char_width + 1 < pane.start_x + pane.width:
448+
sys.stdout.write(f'{ESC}[{y + 1};{x + char_width + 1}H{char}')
450449
sys.stdout.flush()
451450

452451
# Handle second character selection

0 commit comments

Comments
 (0)