mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 15:05:28 +02:00
fix(ssh_config): Check Host options in order
This commit is contained in:
parent
90b62cf01f
commit
6c603f5c5b
@ -1,9 +1,12 @@
|
||||
package analyzer
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"config-lsp/common"
|
||||
"config-lsp/handlers/ssh_config/ast"
|
||||
hostparser "config-lsp/handlers/ssh_config/host-parser"
|
||||
"fmt"
|
||||
"slices"
|
||||
|
||||
protocol "github.com/tliron/glsp/protocol_3_16"
|
||||
)
|
||||
@ -13,7 +16,15 @@ func analyzeHostBlock(
|
||||
) {
|
||||
hosts := make(map[string]*hostparser.HostValue, 0)
|
||||
|
||||
for _, block := range ctx.document.GetAllHostBlocks() {
|
||||
blocks := ctx.document.GetAllHostBlocks()
|
||||
slices.SortFunc(
|
||||
blocks,
|
||||
func(a, b *ast.SSHHostBlock) int {
|
||||
return cmp.Compare(a.Start.Line, b.Start.Line)
|
||||
},
|
||||
)
|
||||
|
||||
for _, block := range blocks {
|
||||
if block == nil || block.HostValue == nil {
|
||||
continue
|
||||
}
|
||||
|
@ -57,6 +57,8 @@ func (d SSHDocument) GetAllMatchBlocks() []*ast.SSHMatchBlock {
|
||||
|
||||
var hostOption = fields.CreateNormalizedName("Host")
|
||||
|
||||
// GetAllHostBlocks: Returns all Host blocks.
|
||||
// Note: This is not sorted
|
||||
func (d SSHDocument) GetAllHostBlocks() []*ast.SSHHostBlock {
|
||||
hostBlocks := make([]*ast.SSHHostBlock, 0, 5)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user