diff options
| author | Teddy Wing | 2021-08-08 20:36:10 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2021-08-08 20:37:59 +0200 | 
| commit | 5950add03889fc9a8cb6faface53903cebf3a206 (patch) | |
| tree | 935c5f758ce72ba8658fabab67c13e78eb7cb5be /incdec.pm | |
| parent | 3a813c6204e4f6879540fb2f44abb71f0406296f (diff) | |
| download | readline-incdec-5950add03889fc9a8cb6faface53903cebf3a206.tar.bz2 | |
incdec: Change a number when the cursor is in the middle of it
Correctly increment a number when the cursor is, for example, at:
    test 12 0
          ^
This causes the #5 test incrementing the second number to fail.
Diffstat (limited to 'incdec.pm')
| -rw-r--r-- | incdec.pm | 7 | 
1 files changed, 7 insertions, 0 deletions
| @@ -9,6 +9,13 @@ sub incdec {  	$point_position ||= 0;  	$is_backward ||= 0; +	$line =~ /(\d+)/; +	# print $-[0] . ':' . $+[0] . ';' . $point_position; + +	if ($-[0] <= $point_position || $point_position <= $+[0]) { +		$point_position = $-[0]; +	} +  	my $line_part = substr $line, $point_position;  	$line_part =~ s/(\d+)/$1+1/e; | 
