diff options
| author | Teddy Wing | 2021-08-08 19:19:58 +0200 |
|---|---|---|
| committer | Teddy Wing | 2021-08-08 19:19:58 +0200 |
| commit | 8c5f0c4a32321df2789b2f2b1992c5d190cd4b45 (patch) | |
| tree | efd3e6fbe495ae853d9d3c54e6b917378daec36e /incdec.pm | |
| parent | 5faf72596a1f5d9e209e10ea35dae5570735ddb4 (diff) | |
| download | readline-incdec-8c5f0c4a32321df2789b2f2b1992c5d190cd4b45.tar.bz2 | |
incdec: Handle increments relative to the cursor position
This will increment the next number to the right of the given cursor
position.
Diffstat (limited to 'incdec.pm')
| -rw-r--r-- | incdec.pm | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -9,7 +9,13 @@ sub incdec { $point_position ||= 0; $is_backward ||= 0; - $line =~ s/(\d+)/$1+1/e; + my $line_part = substr $line, $point_position; + + $line_part =~ s/(\d+)/$1+1/e; + + my $line_excluded = substr $line, 0, $point_position; + + $line = $line_excluded . $line_part; return $line; } |
