diff --git a/common/location.go b/common/location.go index 5db293f..db050e7 100644 --- a/common/location.go +++ b/common/location.go @@ -57,7 +57,7 @@ func (l LocationRange) ToLSPRange() protocol.Range { }, End: protocol.Position{ Line: l.End.Line, - Character: l.End.Character, + Character: l.End.Character + 1, }, } } @@ -115,7 +115,7 @@ func CharacterRangeFromCtx( }, End: Location{ Line: line, - Character: end + 1, + Character: end, }, } } diff --git a/handlers/aliases/ast/parser_test.go b/handlers/aliases/ast/parser_test.go index 9ad9165..17351ea 100644 --- a/handlers/aliases/ast/parser_test.go +++ b/handlers/aliases/ast/parser_test.go @@ -105,11 +105,11 @@ luke: :include:/etc/other_aliases t.Fatalf("Expected path to be '/etc/other_aliases', got %v", includeValue.Path.Path) } - if !(includeValue.Location.Start.Character == 6 && includeValue.Location.End.Character == 33) { + if !(includeValue.Location.Start.Character == 6 && includeValue.Location.End.Character == 32) { t.Fatalf("Expected location to be 6-33, got %v-%v", includeValue.Location.Start.Character, includeValue.Location.End.Character) } - if !(includeValue.Path.Location.Start.Character == 15 && includeValue.Path.Location.End.Character == 33) { + if !(includeValue.Path.Location.Start.Character == 15 && includeValue.Path.Location.End.Character == 32) { t.Fatalf("Expected path location to be 15-33, got %v-%v", includeValue.Path.Location.Start.Character, includeValue.Path.Location.End.Character) } } diff --git a/handlers/hosts/analyzer/handler_test.go b/handlers/hosts/analyzer/handler_test.go index b7182a2..4705c95 100644 --- a/handlers/hosts/analyzer/handler_test.go +++ b/handlers/hosts/analyzer/handler_test.go @@ -51,7 +51,7 @@ func TestValidSimpleExampleWorks( t.Errorf("Expected start to be 0, but got %v", entry.Location.Start) } - if !(entry.Location.End.Character == 17) { + if !(entry.Location.End.Character == 16) { t.Errorf("Expected end to be 17, but got %v", entry.Location.End.Character) } @@ -63,7 +63,7 @@ func TestValidSimpleExampleWorks( t.Errorf("Expected IP address start to be 0, but got %v", entry.IPAddress.Location.Start.Character) } - if !(entry.IPAddress.Location.End.Character == 7) { + if !(entry.IPAddress.Location.End.Character == 6) { t.Errorf("Expected IP address end to be 7, but got %v", entry.IPAddress.Location.End.Character) } diff --git a/handlers/hosts/lsp/text-document-hover.go b/handlers/hosts/lsp/text-document-hover.go index 086daa5..53ceb61 100644 --- a/handlers/hosts/lsp/text-document-hover.go +++ b/handlers/hosts/lsp/text-document-hover.go @@ -49,7 +49,7 @@ func TextDocumentHover( hostname = entry.Hostname case handlers.HoverTargetAlias: for _, alias := range entry.Aliases { - if alias.Location.Start.Character <= character && character <= alias.Location.End.Character { + if character >= alias.Location.Start.Character && character <= alias.Location.End.Character { hostname = alias break } diff --git a/handlers/sshd_config/ast/parser_test.go b/handlers/sshd_config/ast/parser_test.go index 3b3626e..53a0458 100644 --- a/handlers/sshd_config/ast/parser_test.go +++ b/handlers/sshd_config/ast/parser_test.go @@ -31,13 +31,13 @@ PasswordAuthentication yes firstEntry.LocationRange.Start.Line == 0 && firstEntry.LocationRange.End.Line == 0 && firstEntry.LocationRange.Start.Character == 0 && - firstEntry.LocationRange.End.Character == 18 && + firstEntry.LocationRange.End.Character == 17 && firstEntry.Key.Value == "PermitRootLogin" && firstEntry.Key.LocationRange.Start.Character == 0 && - firstEntry.Key.LocationRange.End.Character == 15 && + firstEntry.Key.LocationRange.End.Character == 14 && firstEntry.OptionValue.Value == "no" && firstEntry.OptionValue.LocationRange.Start.Character == 16 && - firstEntry.OptionValue.LocationRange.End.Character == 18) { + firstEntry.OptionValue.LocationRange.End.Character == 17) { t.Errorf("Expected first entry to be PermitRootLogin no, but got: %v", firstEntry) } @@ -48,13 +48,13 @@ PasswordAuthentication yes secondEntry.LocationRange.Start.Line == 1 && secondEntry.LocationRange.End.Line == 1 && secondEntry.LocationRange.Start.Character == 0 && - secondEntry.LocationRange.End.Character == 26 && + secondEntry.LocationRange.End.Character == 25 && secondEntry.Key.Value == "PasswordAuthentication" && secondEntry.Key.LocationRange.Start.Character == 0 && - secondEntry.Key.LocationRange.End.Character == 22 && + secondEntry.Key.LocationRange.End.Character == 21 && secondEntry.OptionValue.Value == "yes" && secondEntry.OptionValue.LocationRange.Start.Character == 23 && - secondEntry.OptionValue.LocationRange.End.Character == 26) { + secondEntry.OptionValue.LocationRange.End.Character == 25) { t.Errorf("Expected second entry to be PasswordAuthentication yes, but got: %v", secondEntry) } }