<s> import re <EOL> import sublime <EOL> import sublime_plugin <EOL> from . filter import PromptFilterToLinesCommand <EOL> from . filter import FilterToLinesCommand <EOL> class PromptFoldToLinesCommand ( PromptFilterToLinesCommand ) : <EOL> def run ( self , search_type = '<STR_LIT:string>' ) : <EOL> self . _run ( search_type , "<STR_LIT>" , "<STR_LIT>" ) <EOL> class FoldToLinesCommand ( FilterToLinesCommand ) : <EOL> def show_filtered_lines ( self , edit , lines ) : <EOL> source_lines = self . view . lines ( sublime . Region ( <NUM_LIT:0> , self . view . size ( ) ) ) <EOL> filtered_line_numbers = [ self . view . rowcol ( line . begin ( ) ) [ <NUM_LIT:0> ] for line , _ in lines ] <EOL> regions = [ ] <EOL> region = None <EOL> for line in source_lines : <EOL> matched = ( self . view . rowcol ( line . begin ( ) ) [ <NUM_LIT:0> ] in filtered_line_numbers ) ^ self . invert_search <EOL> if matched : <EOL> if region : <EOL> regions . append ( region ) <EOL> region = None <EOL> else : <EOL> if region : <EOL> region = region . cover ( line ) <EOL> else : <EOL> region = sublime . Region ( line . begin ( ) , line . end ( ) ) <EOL> if region : <EOL> regions . append ( region ) <EOL> if regions : <EOL> self . view . fold ( regions ) <EOL> def prepare_output_line ( self , line , matches ) : <EOL> pass </s>
