nix-community / rnix-parser

A Nix parser written in Rust [maintainer=@oberblastmeister]
MIT License
366 stars 44 forks source link

Fix trivia tokens being misplaced #63

Closed Ma27 closed 2 years ago

Ma27 commented 2 years ago

Summary & Motivation

While working on #44 I had to split up the internal token-update behavior a bit as we have to decide which node to use (and also which behavior - depending on whether we have a "literal" path or a path with an interpolation).

Unfortunately I wasn't careful enough with checking where trivia tokens (i.e. \n, etc.) were placed.

This lead to situations such as

TOKEN_WHITESPACE(" ") 37..38
TOKEN_WHITESPACE(" ") 38..39
NODE_LITERAL 39..44 {
  TOKEN_PATH("./bar") 39..44

where the second white-space should've been after the path ./bar.

Backwards-incompatible changes

n/a

Further context

Affected versions: 0.10.0. Should be published in a bugfix-release.