mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-25 17:56:34 +08:00
Correct position of the newly imported tokens
This commit is contained in:
parent
d1216f409d
commit
d56a9a1c5d
|
@ -198,12 +198,23 @@ func (p *parser) doImport() error {
|
|||
return p.Errf("No files matching the import pattern %s", importPattern)
|
||||
}
|
||||
|
||||
// Splice out the import directive and its argument (2 tokens total)
|
||||
// and insert the imported tokens in their place.
|
||||
tokensBefore := p.tokens[:p.cursor-1]
|
||||
tokensAfter := p.tokens[p.cursor+1:]
|
||||
// cursor was advanced one position to read filename; rewind it
|
||||
p.cursor--
|
||||
|
||||
p.tokens = tokensBefore
|
||||
|
||||
for _, importFile := range matches {
|
||||
if err := p.doSingleImport(importFile); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
p.tokens = append(p.tokens, append(tokensAfter)...)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -222,10 +233,7 @@ func (p *parser) doSingleImport(importFile string) error {
|
|||
|
||||
// Splice out the import directive and its argument (2 tokens total)
|
||||
// and insert the imported tokens in their place.
|
||||
tokensBefore := p.tokens[:p.cursor-1]
|
||||
tokensAfter := p.tokens[p.cursor+1:]
|
||||
p.tokens = append(tokensBefore, append(importedTokens, tokensAfter...)...)
|
||||
p.cursor-- // cursor was advanced one position to read the filename; rewind it
|
||||
p.tokens = append(p.tokens, append(importedTokens)...)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user