Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made the b command more useful #418

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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