aboutsummaryrefslogtreecommitdiffstats
path: root/incdec.pm
diff options
context:
space:
mode:
authorTeddy Wing2021-08-19 21:43:12 +0200
committerTeddy Wing2021-08-19 21:43:12 +0200
commitaff27d201c023747cc2b99f853ecb82e4f5b609b (patch)
treeb03db29dc1ddf6dcb67b63e8c1a6242df3050016 /incdec.pm
parent2d6c93c03ba8a2392ff09b92bfd51fb8afe7a23c (diff)
downloadreadline-incdec-aff27d201c023747cc2b99f853ecb82e4f5b609b.tar.bz2
incdec: Get backward incrementing working in all cases
Set up the proper condition to get the start index of the number just before point.
Diffstat (limited to 'incdec.pm')
-rw-r--r--incdec.pm12
1 files changed, 7 insertions, 5 deletions
diff --git a/incdec.pm b/incdec.pm
index b05c547..a473e30 100644
--- a/incdec.pm
+++ b/incdec.pm
@@ -13,15 +13,17 @@ sub incdec {
my @points = ();
my $previous_match_start = 0;
my $previous_match_end = 0;
+ print "$line\n";
while ($line =~ /(\d+)/g) {
if ($is_backward) {
- # print "pos[$point_position] -[$-[0]]- +[$+[0]]+\n";
+ print "pos[$point_position] -[$-[0]]- +[$+[0]]+\n";
+ print "pos[$point_position] -[$previous_match_start]- +[$previous_match_end]+\n";
# if $point_position < $-[0]
# && previous $+[0] <= $point_position
- # if ($previous_match_end <= $point_position && $point_position < $-[0]) {
- if ($-[0] <= $point_position && $point_position < $+[0]) {
- # print "matched";
- $start_position = $-[0];
+ if ($previous_match_end - 1 <= $point_position && $point_position < $-[0]) {
+ # if ($-[0] <= $point_position && $point_position < $+[0]) {
+ print "matched at $-[0];$previous_match_end\n";
+ $start_position = $previous_match_start;
last;
}