#NEWLINE# def run( self , edit ) : #NEWLINE# #INDENT# if ( int ( sublime . version ( ) ) >= 3080 ) : #NEWLINE# #INDENT# self . sublime_vars = self . view . window ( ) . extract_variables ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# file = self . view . file_name ( ) #NEWLINE# self . sublime_vars = { #NEWLINE# #INDENT# 'file' : file , #NEWLINE# 'file_path' : dirname ( file ) , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# file_name = ( self . sublime_vars [ 'file' ] if ( 'file' in self . sublime_vars ) else 'unsaved buffer' ) #NEWLINE# if ( not self . has_selection ( ) ) : #NEWLINE# #INDENT# sublime . status_message ( ( 'Stylefmt: format ' + file_name ) ) #NEWLINE# region = sublime . Region ( 0 , self . view . size ( ) ) #NEWLINE# originalBuffer = self . view . substr ( region ) #NEWLINE# formatted = self . format ( originalBuffer ) #NEWLINE# if file : #NEWLINE# #INDENT# self . view . replace ( edit , region , formatted ) #NEWLINE# #UNINDENT# return #NEWLINE# #UNINDENT# for region in self . view . sel ( ) : #NEWLINE# #INDENT# sublime . status_message ( ( 'Stylefmt: format region(s) in ' + file_name ) ) #NEWLINE# if region . empty ( ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# originalBuffer = self . view . substr ( region ) #NEWLINE# formatted = self . format ( originalBuffer ) #NEWLINE# if formatted : #NEWLINE# #INDENT# self . view . replace ( edit , region , formatted )