diff --git a/src/language_server_api.h b/src/language_server_api.h index 289df238..58220560 100644 --- a/src/language_server_api.h +++ b/src/language_server_api.h @@ -468,15 +468,6 @@ struct lsFormattingOptions { }; MAKE_REFLECT_STRUCT(lsFormattingOptions, tabSize, insertSpaces); -struct lsTextDocumentFormattingParams { - // The text document. - lsTextDocumentIdentifier textDocument; - - // The format options, like tabs or spaces. - lsFormattingOptions options; -}; -MAKE_REFLECT_STRUCT(lsTextDocumentFormattingParams, textDocument, options); - // A document highlight is a range inside a text document which deserves // special attention. Usually a document highlight is visualized by changing // the background color of its range. diff --git a/src/messages/text_document_formatting.cc b/src/messages/text_document_formatting.cc index 5ef978d7..c67dc412 100644 --- a/src/messages/text_document_formatting.cc +++ b/src/messages/text_document_formatting.cc @@ -6,6 +6,13 @@ #include namespace { + +struct lsTextDocumentFormattingParams { + lsTextDocumentIdentifier textDocument; + lsFormattingOptions options; +}; +MAKE_REFLECT_STRUCT(lsTextDocumentFormattingParams, textDocument, options); + struct Ipc_TextDocumentFormatting : public IpcMessage { const static IpcId kIpcId = IpcId::TextDocumentFormatting; diff --git a/src/messages/text_document_range_formatting.cc b/src/messages/text_document_range_formatting.cc index 01d78a63..5eb6a2d6 100644 --- a/src/messages/text_document_range_formatting.cc +++ b/src/messages/text_document_range_formatting.cc @@ -7,15 +7,25 @@ #include namespace { + +struct lsTextDocumentRangeFormattingParams { + lsTextDocumentIdentifier textDocument; + lsRange range; + lsFormattingOptions options; +}; +MAKE_REFLECT_STRUCT(lsTextDocumentRangeFormattingParams, + textDocument, + range, + options); + struct Ipc_TextDocumentRangeFormatting : public IpcMessage { const static IpcId kIpcId = IpcId::TextDocumentRangeFormatting; lsRequestId id; - lsRange range; - lsTextDocumentFormattingParams params; + lsTextDocumentRangeFormattingParams params; }; -MAKE_REFLECT_STRUCT(Ipc_TextDocumentRangeFormatting, id, range, params); +MAKE_REFLECT_STRUCT(Ipc_TextDocumentRangeFormatting, id, params); REGISTER_IPC_MESSAGE(Ipc_TextDocumentRangeFormatting); struct Out_TextDocumentRangeFormatting @@ -40,9 +50,9 @@ struct TextDocumentRangeFormattingHandler WorkingFile* working_file = working_files->GetFileByFilename(file->def->path); - int start = GetOffsetForPosition(request->range.start, + int start = GetOffsetForPosition(request->params.range.start, working_file->buffer_content), - end = GetOffsetForPosition(request->range.end, + end = GetOffsetForPosition(request->params.range.end, working_file->buffer_content); response.result = ConvertClangReplacementsIntoTextEdits( working_file->buffer_content,