Skip to content

Commit ffe7728

Browse files
committedOct 21, 2018
pipe: re-use change command for correct behavior
1 parent 5f0a965 commit ffe7728

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed
 

‎cmd.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (c WriteFile) Apply(ed Editor) {
8686

8787
func (c Pipe) Apply(ed Editor) {
8888
x := strings.Fields(c.To)
89-
if len(x) == 0 {
89+
if len(x) == 0 || x[0] == "" {
9090
eprint("|: nothing on rhs")
9191
}
9292
n := x[0]
@@ -103,8 +103,7 @@ func (c Pipe) Apply(ed Editor) {
103103
if err != nil {
104104
eprint(err)
105105
}
106-
ed.Delete(q0, q1)
107-
ed.Insert(buf.Bytes(), q0)
106+
Change{To: buf.Bytes()}.Apply(ed)
108107
}
109108
func (c S) Apply(ed Editor) {
110109
sp, ep := ed.Dot()

0 commit comments

Comments
 (0)
Please sign in to comment.