From 04fe0d2dc8fa8e6a1d1080aa74e5351575df7e4c Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Sat, 10 Aug 2024 17:23:58 +0200 Subject: [PATCH] fix: Overall improvements --- doc-values/value-key-enum-assignment.go | 2 ++ handlers/fstab/parser.go | 21 +++++++++++++++++++++ handlers/fstab/text-document-completion.go | 1 - 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/doc-values/value-key-enum-assignment.go b/doc-values/value-key-enum-assignment.go index 3f69a13..c6e297c 100644 --- a/doc-values/value-key-enum-assignment.go +++ b/doc-values/value-key-enum-assignment.go @@ -114,6 +114,7 @@ func (v KeyEnumAssignmentValue) FetchEnumCompletions() []protocol.CompletionItem kind := protocol.CompletionItemKindField val := v.Values[enumKey] description := val.GetTypeDescription() + insertText := enumKey.InsertText + v.Separator var documentation string @@ -125,6 +126,7 @@ func (v KeyEnumAssignmentValue) FetchEnumCompletions() []protocol.CompletionItem completions = append(completions, protocol.CompletionItem{ Label: enumKey.InsertText, + InsertText: &insertText, InsertTextFormat: &textFormat, Kind: &kind, Documentation: documentation, diff --git a/handlers/fstab/parser.go b/handlers/fstab/parser.go index 5ca9a5d..429edd8 100644 --- a/handlers/fstab/parser.go +++ b/handlers/fstab/parser.go @@ -211,6 +211,11 @@ func (p *FstabParser) AddLine(line string, lineNumber int) error { case 6: value := fields[5] start := uint32(strings.Index(line, value)) + + if start == 0 { + start = uint32(len(line)) + } + pass = &Field{ Value: fields[5], Start: start, @@ -221,6 +226,10 @@ func (p *FstabParser) AddLine(line string, lineNumber int) error { value := fields[4] start := uint32(strings.Index(line, value)) + if start == 0 { + start = uint32(len(line)) + } + freq = &Field{ Value: value, Start: start, @@ -231,6 +240,10 @@ func (p *FstabParser) AddLine(line string, lineNumber int) error { value := fields[3] start := uint32(strings.Index(line, value)) + if start == 0 { + start = uint32(len(line)) + } + options = &Field{ Value: value, Start: start, @@ -241,6 +254,10 @@ func (p *FstabParser) AddLine(line string, lineNumber int) error { value := fields[2] start := uint32(strings.Index(line, value)) + if start == 0 { + start = uint32(len(line)) + } + filesystemType = &Field{ Value: value, Start: start, @@ -251,6 +268,10 @@ func (p *FstabParser) AddLine(line string, lineNumber int) error { value := fields[1] start := uint32(strings.Index(line, value)) + if start == 0 { + start = uint32(len(line)) + } + mountPoint = &Field{ Value: value, Start: start, diff --git a/handlers/fstab/text-document-completion.go b/handlers/fstab/text-document-completion.go index 7cec50f..6b2a174 100644 --- a/handlers/fstab/text-document-completion.go +++ b/handlers/fstab/text-document-completion.go @@ -3,7 +3,6 @@ package fstab import ( docvalues "config-lsp/doc-values" fstabdocumentation "config-lsp/handlers/fstab/documentation" - "fmt" "github.com/tliron/glsp" protocol "github.com/tliron/glsp/protocol_3_16"