Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def match_text_for_idx idx
- match = truncated_match @matches[idx]
- if idx == @selection
- prefix = @@selection_marker
- suffix = padding_for_selected_match match
- else
- prefix = @@unselected_marker
- suffix = ''
- end
- prefix + file_name(match) + match + suffix
- end
- def file_name(match)
- file = match.split('/').last
- if file.length >= 50
- shorten_file_name(file)
- else
- spaces = 50 - file.length
- file = file + " " * (spaces)
- end
- end
- def shorten_file_name match
- len = match.length
- max_width = 50
- return match if len <= max_width
- left = (max_width / 2) - 1
- right = (max_width / 2) - 2 + (max_width % 2)
- match[0, left] + '...' + match[-right, right]
- end
Add Comment
Please, Sign In to add comment