Skip to content

Commit

Permalink
Fix bug in opening file whose names contains spaces
Browse files Browse the repository at this point in the history
The code to open files whose names contain spaces had an off-by-1
error and didn't work when right-clicking a selection including
quotes. Fix this.
  • Loading branch information
rjkroege committed Feb 11, 2025
1 parent 0e8ddae commit a6011d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions expandfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ func findquotedcontext(t *Text, q0 int) (qq0, qq1 int) {
}
// TODO(rjk): Should give up at a max filename length.
for qq1 < t.file.Nr() {
c := t.ReadC(qq1 - 1)
// TODO(rjk): why -1?
c := t.ReadC(qq1)
// c := t.ReadC(qq1 - 1)
if c == '\'' {
break
return qq0, qq1 + 1
}
if !isfilec(c) && !isfilespace(c) {
return q0, q0 // No quote found rightwards.
Expand Down
4 changes: 4 additions & 0 deletions file/observable_editable_buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,10 @@ func (e *ObservableEditableBuffer) String() string {
return e.f.String()
}

func (e *ObservableEditableBuffer) StringSlice(rq0 int, rq1 int) string {
return e.f.StringSlice(rq0, rq1)
}

// ResetBuffer is a forwarding function for rune_array.Reset. Equivalent
// to re-creating the buffer.
func (e *ObservableEditableBuffer) ResetBuffer() {
Expand Down

0 comments on commit a6011d1

Please sign in to comment.