diff --git a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp index e0bba9e9fc7830..3b1dfcc6195e38 100644 --- a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp +++ b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp @@ -87,7 +87,8 @@ getLocationFromLoc(llvm::SourceMgr &sourceMgr, Location loc, if (Optional range = AsmParserState::convertIdLocToRange(loc)) { auto lineCol = sourceMgr.getLineAndColumn(range->End); - location->range.end.character = lineCol.second - 1; + location->range.end.character = + std::max(fileLoc.getColumn() + 1, lineCol.second - 1); } return WalkResult::interrupt(); }