<s> """<STR_LIT>""" <EOL> import sublime <EOL> import sublime_plugin <EOL> try : <EOL> from . import headline <EOL> from . utilities import is_region_void <EOL> except ValueError : <EOL> import headline <EOL> from utilities import is_region_void <EOL> class HeadlineMoveCommand ( sublime_plugin . TextCommand ) : <EOL> def run ( self , edit , forward = True , same_level = True ) : <EOL> """<STR_LIT>""" <EOL> new_sel = [ ] <EOL> if same_level : <EOL> level_type = headline . MATCH_PARENT <EOL> else : <EOL> level_type = headline . MATCH_ANY <EOL> for region in self . view . sel ( ) : <EOL> if same_level : <EOL> _ , level = headline . headline_and_level_at_point ( self . view , region . a , <EOL> search_above_and_down = True ) <EOL> if level is None : <EOL> return <EOL> else : <EOL> level = headline . ANY_LEVEL <EOL> match_region , _ = headline . find_headline ( self . view , region . a , level , forward , level_type , skip_headline_at_point = True , skip_folded = True ) <EOL> if is_region_void ( match_region ) : <EOL> return <EOL> new_sel . append ( sublime . Region ( match_region . a , match_region . a ) ) <EOL> self . adjust_view ( new_sel ) <EOL> def adjust_view ( self , new_sel ) : <EOL> self . view . sel ( ) . clear ( ) <EOL> for region in new_sel : <EOL> self . view . sel ( ) . add ( region ) <EOL> self . view . show ( region ) </s>
