Changeset 7489


Ignore:
Timestamp:
08/23/09 07:24:25 (2 years ago)
Author:
azawawi
Message:

[Padre] Perl's 'use strict; use warnings;' is implemented. Not refactored though :)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Padre/lib/Padre/QuickFixProvider/Perl.pm

    r7488 r7489  
    3333    my $current_line_no = $editor->GetCurrentLine; 
    3434 
    35     if ( $text !~ /^\s*use strict/msx ) { 
     35    if ( $text !~ /\s*use\s+strict/msx ) { 
    3636        push @items, { 
    3737            text     => qq{Add 'use strict;'}, 
    3838            listener => sub { 
    39                 $text = 'use strict;' . $text; 
    40                 } 
     39                my $line_start = $editor->PositionFromLine($current_line_no); 
     40                my $line_end   = $editor->GetLineEndPosition($current_line_no); 
     41                my $line = $editor->GetTextRange($line_start,$line_end); 
     42                $line = qq{use strict;$line\n}; 
     43                $editor->SetSelection( $line_start, $line_end ); 
     44                $editor->ReplaceSelection($line); 
     45            } 
    4146        }; 
    4247    } 
    43     if ( $text !~ /^\s*use warnings/msx ) { 
     48    if ( $text !~ /\s*use\s+warnings/msx ) { 
    4449        push @items, { 
    4550            text     => qq{Add 'use warnings;'}, 
    4651            listener => sub { 
    47                 $text = 'use warnings;' . $text; 
    48  
    49                 #$editor->ReplaceSelection( 
    50                 } 
     52                my $line_start = $editor->PositionFromLine($current_line_no); 
     53                my $line_end   = $editor->GetLineEndPosition($current_line_no); 
     54                my $line = $editor->GetTextRange($line_start,$line_end); 
     55                $line = qq{use warnings;$line\n}; 
     56                $editor->SetSelection( $line_start, $line_end ); 
     57                $editor->ReplaceSelection($line); 
     58            } 
    5159        }; 
    5260    } 
Note: See TracChangeset for help on using the changeset viewer.