mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-19 07:25:27 +02:00
fix(wireguard): Improvements
This commit is contained in:
parent
b08a5b68bf
commit
d456f4a569
@ -134,7 +134,7 @@ func (p *wireguardParser) parseFromString(input string) []lineError {
|
|||||||
return errors
|
return errors
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *wireguardParser) getTypeByLine(line uint32) lineType {
|
func (p wireguardParser) getTypeByLine(line uint32) lineType {
|
||||||
// Check if line is a comment
|
// Check if line is a comment
|
||||||
if _, found := p.CommentLines[line]; found {
|
if _, found := p.CommentLines[line]; found {
|
||||||
return LineTypeComment
|
return LineTypeComment
|
||||||
@ -168,13 +168,10 @@ func (p *wireguardParser) getTypeByLine(line uint32) lineType {
|
|||||||
// [Peer]
|
// [Peer]
|
||||||
//
|
//
|
||||||
// This would return the section [Interface]
|
// This would return the section [Interface]
|
||||||
func (p *wireguardParser) getBelongingSectionByLine(line uint32) *wireguardSection {
|
func (p wireguardParser) getBelongingSectionByLine(line uint32) *wireguardSection {
|
||||||
// Create a copy
|
for index := range p.Sections {
|
||||||
sections := append([]wireguardSection{}, p.Sections...)
|
section := p.Sections[len(p.Sections)-index-1]
|
||||||
|
|
||||||
slices.Reverse(sections)
|
|
||||||
|
|
||||||
for _, section := range sections {
|
|
||||||
if section.StartLine <= line && section.Name != nil {
|
if section.StartLine <= line && section.Name != nil {
|
||||||
return §ion
|
return §ion
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user