<s> import sublime <EOL> import sublime_plugin <EOL> import os <EOL> class TabFilterCommand ( sublime_plugin . WindowCommand ) : <EOL> """<STR_LIT>""" <EOL> def run ( self ) : <EOL> """<STR_LIT>""" <EOL> window = sublime . active_window ( ) <EOL> names = [ ] <EOL> captions = [ ] <EOL> dirs = [ ] <EOL> self . views = [ ] <EOL> self . prefix = "<STR_LIT>" <EOL> self . settings = sublime . load_settings ( "<STR_LIT>" ) <EOL> for view in window . views ( ) : <EOL> self . views . append ( view ) <EOL> if view . file_name ( ) is None : <EOL> name = view . name ( ) <EOL> if len ( name ) == <NUM_LIT:0> : <EOL> name = "<STR_LIT>" <EOL> else : <EOL> name = view . file_name ( ) <EOL> dirs . append ( os . path . dirname ( view . file_name ( ) ) + os . path . sep ) <EOL> names . append ( name ) <EOL> if self . settings . get ( "<STR_LIT>" , True ) : <EOL> view_captions = [ ] <EOL> if window . get_view_index ( window . active_view ( ) ) == window . get_view_index ( view ) : <EOL> view_captions . append ( "<STR_LIT>" ) <EOL> if view . file_name ( ) is None : <EOL> view_captions . append ( "<STR_LIT>" ) <EOL> elif view . is_dirty ( ) : <EOL> view_captions . append ( "<STR_LIT>" ) <EOL> if view . is_read_only ( ) : <EOL> view_captions . append ( "<STR_LIT>" ) <EOL> caption = "<STR_LIT:U+002CU+0020>" . join ( view_captions ) <EOL> captions . append ( caption ) <EOL> self . prefix = os . path . commonprefix ( dirs ) <EOL> if self . settings . get ( "<STR_LIT>" , True ) : <EOL> tabs = [ [ os . path . basename ( path ) , path . replace ( self . prefix , '<STR_LIT>' ) , caption ] for path , caption in zip ( names , captions ) ] <EOL> else : <EOL> tabs = [ [ os . path . basename ( path ) , path . replace ( self . prefix , '<STR_LIT>' ) ] for path in names ] <EOL> window . show_quick_panel ( tabs , self . _on_done ) <EOL> def _on_done ( self , index ) : <EOL> """<STR_LIT>""" <EOL> if index > - <NUM_LIT:1> : <EOL> sublime . active_window ( ) . focus_view ( self . views [ index ] ) </s>
