Changeset 5612


Ignore:
Timestamp:
06/26/09 13:16:45 (3 years ago)
Author:
claudio
Message:

Refactor selection buffer to a constant with a comment warning about a reasonable size

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Padre-Plugin-PerlTidy/lib/Padre/Plugin/PerlTidy.pm

    r5590 r5612  
    2424use Padre::Wx      (); 
    2525use Padre::Plugin  (); 
    26  
    27 our $VERSION = '0.07'; 
     26use constant {  SELECTIONSIZE => 40, }; # this constant is used when storing  
     27                    # and restoring the cursor position. 
     28                    # Keep it small to limit resource use. 
     29our $VERSION  = '0.07'; 
    2830our @ISA     = 'Padre::Plugin'; 
    2931 
     
    231233    # parameter: $main, compiled regex 
    232234    my ( $main, $regex, $start ) = @_; 
    233     my $shuffle = 40; 
    234235    my $doc     = $main->current->document; 
    235236    my $editor  = $doc->editor; 
    236237    my $text    = $editor->GetTextRange( 
    237         ( $start - $shuffle ) > 0 ? $start - $shuffle 
     238        ( $start - SELECTIONSIZE ) > 0 ? $start - SELECTIONSIZE 
    238239        : 0, 
    239         ( $start + $shuffle < $editor->GetLength() ) ? $start + $shuffle 
     240        ( $start + SELECTIONSIZE < $editor->GetLength() ) ? $start + SELECTIONSIZE 
    240241        : $editor->GetLength() 
    241242    ); 
     
    260261    my $editor = $doc->editor; 
    261262    my $pos    = $editor->GetCurrentPos; 
    262  
    263     # A smaller selection to save memory  
    264     my $sel_width = 40;    # chars before 
    265263    my $start; 
    266264 
    267     if ( ( $pos - $sel_width ) > 0 ) { 
    268         $start = $pos - $sel_width; 
     265    if ( ( $pos - SELECTIONSIZE ) > 0 ) { 
     266        $start = $pos - SELECTIONSIZE; 
    269267    } 
    270268    else { 
Note: See TracChangeset for help on using the changeset viewer.