Skip to content

Commit

Permalink
Changed alltofile to search by regex rather than find an exact match.
Browse files Browse the repository at this point in the history
  • Loading branch information
camsn0w committed Jan 27, 2022
1 parent d0f2601 commit b90ae5b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
17 changes: 12 additions & 5 deletions ecmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ type ToOEB struct {
r string
}

func alltofile(w *Window, tp *ToOEB) {
func alltofile(w *Window, tp *ToOEB, filenameregex *AcmeRegexp) {
if tp.oeb != nil {
return
}
Expand All @@ -1078,8 +1078,9 @@ func alltofile(w *Window, tp *ToOEB) {
return
}
// if w.nopen[QWevent] > 0 {
// return;
if tp.r == t.file.Name() {
// return

if filenameregex.FindString(t.file.Name()) != "" {
tp.oeb = t.file
}
}
Expand All @@ -1089,9 +1090,15 @@ func toOEB(r string) *file.ObservableEditableBuffer {

t.r = strings.TrimLeft(r, " \t\n")
t.oeb = nil
global.row.AllWindows(func(w *Window) { alltofile(w, &t) })

filenameregex, err := rxcompile(t.r)
if err != nil {
editerror("match not found for\"%v\"", t.r)
}

global.row.AllWindows(func(w *Window) { alltofile(w, &t, filenameregex) })
if t.oeb == nil {
editerror("no such file\"%v\"", t.r)
editerror("match not found for\"%v\"", t.r)
}
return t.oeb
}
Expand Down
11 changes: 11 additions & 0 deletions edit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,12 @@ func TestEditMultipleWindows(t *testing.T) {
t.Fatalf("can't make a temp file because: %v\n", err)
}

fn4, cleaner, err := makeTempFile("file four\n")
defer cleaner()
if err != nil {
t.Fatalf("can't make a temp file because: %v\n", err)
}

testtab := []struct {
dot Range
filename string
Expand Down Expand Up @@ -376,6 +382,10 @@ func TestEditMultipleWindows(t *testing.T) {
// " + alt_example_2\n'+. alt_example_2\n", // NB: scaffold-built buffer starts as not-dirty
" + alt_example_2\n +. alt_example_2\n", // NB: scaffold-built buffer starts as not-dirty
}},
{Range{0, 0}, fn4, "b " + fn4[:len(fn4)-2] + "." + "\ni/Outer Space/", []string{
"Outer Space" + contents,
alt_contents,
}, []string{"'+. " + fn4 + "\n"}},

// u
// 10
Expand Down Expand Up @@ -434,6 +444,7 @@ func TestEditMultipleWindows(t *testing.T) {
}

if got, want := len(warnings), len(test.expectedwarns); got != want {
fmt.Printf("Warnings: %v", warnings[0].buf.String())
t.Errorf("test %d: expected %d warnings but got %d warnings", i, want, got)
return
}
Expand Down

0 comments on commit b90ae5b

Please sign in to comment.