@@ -752,15 +752,21 @@ def replace_text(self, index, string):
752752            return  string 
753753
754754    def  remove_text (self , index , string ):
755-         length  =  len (string )  -   1 
756-          from_index   =   min ( self . remove_from_spin . get_value_as_int ()  -   1 ,  length ) 
757-         to_index  =  min ( self .remove_to_spin .get_value_as_int () -  1 ,  length ) 
755+         length  =  len (string )
756+ 
757+         from_index  =  self .remove_from_spin .get_value_as_int () -  1 
758758        if  self .remove_from_check .get_active ():
759-             from_index  =  length  -  from_index 
759+             from_index  =  max (length  -  from_index , 0 )
760+         else :
761+             from_index  =  min (length , from_index )
762+ 
763+         to_index  =  self .remove_to_spin .get_value_as_int () -  1 
760764        if  self .remove_to_check .get_active ():
761-             to_index  =  length  -  to_index 
762-         to_index  =  max (to_index  +  1 , from_index )
763-         return  string [0 :from_index ]+ string [to_index :]
765+             to_index  =  max (length  -  to_index , 0 )
766+         else :
767+             to_index  =  min (length , to_index )
768+ 
769+         return  string [0 :min (from_index , to_index )] +  string [max (from_index , to_index ):]
764770
765771    def  insert_text (self , index , string ):
766772        text  =  self .insert_entry .get_text ()
0 commit comments