diff --git a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp --- a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp +++ b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp @@ -57,10 +57,15 @@ return llvm::None; } - lsp::Position position; - position.line = loc.getLine() - 1; - position.character = loc.getColumn(); - return lsp::Location{*sourceURI, lsp::Range(position)}; + lsp::Position positionStart; + positionStart.line = loc.getLine() - 1; + positionStart.character = loc.getColumn(); + // FIXME: Arbitrarily choose an end up point 3 characters post start for + // frontends where underlining only happens if the range is non-empty. This + // does not consider actual file contents (incl new lines). + lsp::Position positionEnd(positionStart); + positionEnd.character += 3; + return lsp::Location{*sourceURI, lsp::Range(positionStart, positionEnd)}; } /// Returns a language server location from the given MLIR location, or None if diff --git a/mlir/test/mlir-lsp-server/diagnostics.test b/mlir/test/mlir-lsp-server/diagnostics.test --- a/mlir/test/mlir-lsp-server/diagnostics.test +++ b/mlir/test/mlir-lsp-server/diagnostics.test @@ -15,7 +15,7 @@ // CHECK-NEXT: "message": "custom op 'func' expected valid '@'-identifier for symbol name", // CHECK-NEXT: "range": { // CHECK-NEXT: "end": { -// CHECK-NEXT: "character": 6, +// CHECK-NEXT: "character": 9, // CHECK-NEXT: "line": 0 // CHECK-NEXT: }, // CHECK-NEXT: "start": {