File tree Expand file tree Collapse file tree 1 file changed +8
-15
lines changed Expand file tree Collapse file tree 1 file changed +8
-15
lines changed Original file line number Diff line number Diff line change @@ -540,24 +540,17 @@ def find_matches(panes, search_ch):
540540
541541 for pane in panes :
542542 for line_num , line in enumerate (pane .lines ):
543- pos = 0
544- while pos < len (line ):
545- found = False
543+ # 對每個字符位置檢查所有可能的匹配
544+ for pos in range (len (line )):
546545 for ch in search_chars :
547546 if CASE_SENSITIVE :
548- idx = line .find (ch , pos )
547+ if pos < len (line ) and line [pos ] == ch :
548+ visual_col = sum (get_char_width (c ) for c in line [:pos ])
549+ matches .append ((pane , line_num , visual_col ))
549550 else :
550- idx = line .lower ().find (ch .lower (), pos )
551- if idx != - 1 :
552- visual_col = sum (get_char_width (c ) for c in line [:idx ])
553- matches .append ((pane , line_num , visual_col ))
554- found = True
555- pos = idx + 1
556- break
557- if not found :
558- # if no match found, move to next position, consider character width
559- if pos < len (line ):
560- pos += 1
551+ if pos < len (line ) and line [pos ].lower () == ch .lower ():
552+ visual_col = sum (get_char_width (c ) for c in line [:pos ])
553+ matches .append ((pane , line_num , visual_col ))
561554
562555 return matches
563556
You can’t perform that action at this time.
0 commit comments