Closed ktye closed 5 years ago
This was done on purpose. The edit package is stateless, so there is no dot to set.
However, the ui
package isn't stateless, and we will want to set dot when the user gives an Edit
command with only an address. We can get to that when we implement Edit
.
In general, sam and the sam manual are useful references, but I don't consider it to be the specification for how T should behave. There are some points where I choose to deviate from sam on purpose. This is one such place.
For the record, the way to handle this is that edit.Edit
should return a named error type in the case of "no command":
// NoCommandError is returned when there was no command to execute.
type NoCommandError struct {
// At contains the evaluation of the address preceding the missing command.
// An empty address is dot, so an empty edit results in a NoCommandError
// At set to the value of dot.
At [2]int64
}
Then the caller, who is the one responsible for maintaining state, can set their dot.
The title is a bit off, because we won't be setting dot, but just returning a valid dot. But this should be open (especially since there is a fix for it coming).
From the sam manual:
Should edit.Edit return a Diff that updates the dot if no command is given? Currently it returns the error "no command".