Skip to content

Commit

Permalink
cue/token: relative positions apply before, not after, a token
Browse files Browse the repository at this point in the history
Maximilian Gaß correctly points out that the cue/format package
follows relative positions before printing a token, and he's right.
I also confirmed that the token scanner also builds relative positions
based on the kind of whitespace it found leading up to each token.

While here, fix a typo.

Signed-off-by: Daniel Martí <[email protected]>
Change-Id: I2eae7f628a4e585e966e029d9d78c7fe3be89539
Dispatch-Trailer: {"type":"trybot","CL":1186143,"patchset":1,"ref":"refs/changes/43/1186143/1","targetBranch":"master"}
  • Loading branch information
mvdan authored and cueckoo committed Mar 22, 2024
1 parent e4e6d68 commit 2672735
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cue/token/position.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,16 @@ const (
// not rendered at all.
Elided

// NoSpace indicates there is no whitespace after this token.
// NoSpace indicates there is no whitespace before this token.
NoSpace

// Blank means there is horizontal space after this token.
// Blank means there is horizontal space before this token.
Blank

// Newline means there is a single newline after this token.
// Newline means there is a single newline before this token.
Newline

// NewSection means there are two or more newlines after this token.
// NewSection means there are two or more newlines before this token.
NewSection

relMask = 0xf
Expand Down Expand Up @@ -175,7 +175,7 @@ func (p Pos) IsValid() bool {
}

// IsNewline reports whether the relative information suggests this node should
// be printed on a new lien.
// be printed on a new line.
func (p Pos) IsNewline() bool {
return p.RelPos() >= Newline
}
Expand Down

0 comments on commit 2672735

Please sign in to comment.