caddyfile: Fix comparing if two tokens are on the same line (#5626)

* fix comparing if two tokens are on the same line

* compare tokens from copies when importing
This commit is contained in:
WeidiDeng
2023-07-13 04:32:22 +08:00
committed by GitHub
parent 0e2c7e1d35
commit bbe1952a59
4 changed files with 103 additions and 25 deletions

View File

@ -464,7 +464,7 @@ func (p *parser) doImport(nesting int) error {
// format, won't check for nesting correctness or any other error, that's what parser does.
if !maybeSnippet && nesting == 0 {
// first of the line
if i == 0 || importedTokens[i-1].File != token.File || importedTokens[i-1].Line+importedTokens[i-1].NumLineBreaks() < token.Line {
if i == 0 || isNextOnNewLine(tokensCopy[i-1], token) {
index = 0
} else {
index++