Skip to content

Commit

Permalink
ed: allow repeated search with // and ??
Browse files Browse the repository at this point in the history
* In commit 78d5429, repeat search was only implemented for "/" and "?"
* Add support for empty patterns specified as "??" and "//" (these may be followed by whitespace, but single "?" and "/" may not)
* test1: "/\n" --> repeat search down
* test2: "/ \n" --> start new search (down) for " "
* test3: "// \n" --> repeat search down
* test4: "?\n" --> repeat search up
* test5: "? \n"--> start new search (up) for " "
* test6: "?? \n --> repeat search up
* Entering //n doesn't seem to work for repeating search then issuing n command (this could be supported later)
  • Loading branch information
mknos authored Oct 23, 2024
1 parent 9f891d0 commit 3c4b664
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bin/ed
Original file line number Diff line number Diff line change
Expand Up @@ -886,14 +886,14 @@ sub edSetCurrentLine {

sub edParse {
s/\A\s+//;
if (m/\A(\/|\?)\z/) {
if (m/\A(\/|\?)\z/ || m/\A(\/{2}|\?{2})\s*\z/) {
unless (defined $SearchPat) {
edWarn(E_NOPAT);
$command = 'nop';
return 1;
}
my $found;
if ($1 eq '/') {
if ($1 eq '/' || $1 eq '//') {
$found = edSearchForward($SearchPat);
} else {
$found = edSearchBackward($SearchPat);
Expand Down

0 comments on commit 3c4b664

Please sign in to comment.