From e9f80bec539e3c88dac18259a1e8920e666cf221 Mon Sep 17 00:00:00 2001 From: Yingchi Long Date: Wed, 12 Jun 2024 21:03:03 +0800 Subject: [PATCH] nixd/Controller: fix character number -> 0 Nixpkgs meta.positions does not have any character information, only line numbers get retrieved. Previously this number will be assigned with randomly, say, equals to line numbers. This PR fixup that character number to zero as if there may be some rendering issue for neovim. Fixes: #523 --- nixd/lib/Controller/Definition.cpp | 2 +- nixd/tools/nixd/test/definition-package.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nixd/lib/Controller/Definition.cpp b/nixd/lib/Controller/Definition.cpp index 6d885f22f..5781b256b 100644 --- a/nixd/lib/Controller/Definition.cpp +++ b/nixd/lib/Controller/Definition.cpp @@ -125,7 +125,7 @@ class NixpkgsDefinitionProvider { }; } int PosL = std::stoi(std::string(Position.substr(Pos + 1))); - lspserver::Position P{PosL, PosL}; + lspserver::Position P{PosL, 0}; std::string_view File = Position.substr(0, Pos); return Location{ .uri = URIForFile::canonicalize(File, File), diff --git a/nixd/tools/nixd/test/definition-package.md b/nixd/tools/nixd/test/definition-package.md index e25d43883..c7ec87d94 100644 --- a/nixd/tools/nixd/test/definition-package.md +++ b/nixd/tools/nixd/test/definition-package.md @@ -62,11 +62,11 @@ CHECK-NEXT: "result": [ CHECK-NEXT: { CHECK-NEXT: "range": { CHECK-NEXT: "end": { -CHECK-NEXT: "character": 33, +CHECK-NEXT: "character": 0, CHECK-NEXT: "line": 33 CHECK-NEXT: }, CHECK-NEXT: "start": { -CHECK-NEXT: "character": 33, +CHECK-NEXT: "character": 0, CHECK-NEXT: "line": 33 CHECK-NEXT: } CHECK-NEXT: },