Skip to content

Commit

Permalink
Broken
Browse files Browse the repository at this point in the history
  • Loading branch information
qvalentin committed Oct 31, 2023
1 parent 92b0420 commit d06dabd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
22 changes: 14 additions & 8 deletions internal/adapter/yamlls/trimTemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,28 @@ func prettyPrintNode(node *sitter.Node, previous []byte, result []byte) {
for i := 0; i < int(childCount); i++ {
logger.Debug("FieldName", node.FieldNameForChild(i))
child := node.Child(i)
logger.Println("FieldNameForChild in in_action: ", node.FieldNameForChild(i))

if child.Type() == "end" {
earaseTemplate(child, previous, result)
earaseTemplate(child.NextSibling(), previous, result)
earaseTemplate(child.PrevSibling(), previous, result)
break
} else if "condition" == node.FieldNameForChild(i) {
if_action_condition := child
if_action_condition_content := child.Content(previous)
logger.Println("if_action_condition_content: ", if_action_condition_content)
earaseTemplate(if_action_condition, previous, result)
earaseTemplate(if_action_condition.NextSibling(), previous, result)
if if_action_condition.PrevSibling() != nil && if_action_condition.PrevSibling().Type() == "if" {
earaseTemplate(if_action_condition.PrevSibling(), previous, result)
earaseTemplate(if_action_condition.PrevSibling().PrevSibling(), previous, result)
}
} else {
prettyPrintNode(child, previous, result)
}
}
if_action_condition := node.ChildByFieldName("condition")
earaseTemplate(if_action_condition, previous, result)
earaseTemplate(if_action_condition.NextSibling(), previous, result)
if if_action_condition.PrevSibling() != nil && if_action_condition.PrevSibling().Type() == "if" {
earaseTemplate(if_action_condition.PrevSibling(), previous, result)
earaseTemplate(if_action_condition.PrevSibling().PrevSibling(), previous, result)
}

case "block_action", "with_action", "range_action":
for i := 0; i < int(childCount); i++ {
child := node.Child(i)
Expand Down Expand Up @@ -78,7 +84,7 @@ func prettyPrintNode(node *sitter.Node, previous []byte, result []byte) {
}

func earaseTemplate(node *sitter.Node, previous []byte, result []byte) {
logger.Debug("Content that is earased", node.Content(previous))
logger.Println("Content that is earased", node.Content(previous))
for i := range []byte(node.Content(previous)) {
result[int(node.StartByte())+i] = byte(' ')
}
Expand Down
13 changes: 2 additions & 11 deletions internal/adapter/yamlls/trimTemplate_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package yamlls

import (
lsplocal "github.com/mrjosh/helm-ls/internal/lsp"
"testing"

lsplocal "github.com/mrjosh/helm-ls/internal/lsp"
)

type TrimTemplateTestData struct {
Expand Down Expand Up @@ -172,11 +173,6 @@ metadata:
httpGet:
path: /healthz
port: {{ .Values.controller.containerPorts.controller }}
initialDelaySeconds: {{ .Values.controller.startupProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.controller.startupProbe.periodSeconds }}
timeoutSeconds: {{ .Values.controller.startupProbe.timeoutSeconds }}
successThreshold: {{ .Values.controller.startupProbe.successThreshold }}
failureThreshold: {{ .Values.controller.startupProbe.failureThreshold }}
{{- end }}
`,
trimmedText: `
Expand All @@ -187,11 +183,6 @@ metadata:
httpGet:
path: /healthz
port: {{ .Values.controller.containerPorts.controller }}
initialDelaySeconds: {{ .Values.controller.startupProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.controller.startupProbe.periodSeconds }}
timeoutSeconds: {{ .Values.controller.startupProbe.timeoutSeconds }}
successThreshold: {{ .Values.controller.startupProbe.successThreshold }}
failureThreshold: {{ .Values.controller.startupProbe.failureThreshold }}
`,
},
Expand Down

0 comments on commit d06dabd

Please sign in to comment.