modify :s check to avoid looping forever

Review Request #102140 - Created July 29, 2011 and submitted

Information
Erlend Hamberg
kate
Reviewers
kate
beschow
the substitute command “s/$/x/g” would loop forever. it makes no sense to add
the ‘g’ at the end of a substitutions that replaces at EOL, but for many this
is appended out of habit.

the check at the end of the replacement code makes sure that the replacement
column is within the line, but since one replacement has already been done, and
$/EOL is the last possible position where a replacement can happen, it makes no
sense that the new start column is equal to the line length (i.e. after the
line) either.

the test should therefore be against line length minus one.
a test making sure that s/$/x/g and s/.*/x/g work correctly has been added.
Erlend Hamberg
Review request changed
Milian Wolff
sounds good to me
Dominik Haumann
Is there any documentation in the handbook that needs to be updated with this change?
  1. Nope. The only behaviour change is an infinite loop that should no longer occur.
Commit Hook
This review has been submitted with commit b56518a32360a3e4305f40dd9903d8193a4f2710 by Erlend Hamberg to branch master.
Loading...