From 34039d663925670e011db2cc6e96a120a667308a Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Sun, 4 Oct 2020 11:16:13 +0330 Subject: [PATCH] HackStudio: Do not change the cursor in the LSP autocomplete request The C++ completion somehow depends on this, so move that behaviour into the C++ language server instead. --- DevTools/HackStudio/Editor.cpp | 2 +- DevTools/HackStudio/LanguageServers/Cpp/ClientConnection.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DevTools/HackStudio/Editor.cpp b/DevTools/HackStudio/Editor.cpp index 45398c1b353..13e07f4188a 100644 --- a/DevTools/HackStudio/Editor.cpp +++ b/DevTools/HackStudio/Editor.cpp @@ -497,7 +497,7 @@ Optional Editor::get_autocomplete_request_data( if (!wrapper().editor().m_language_client) return {}; - return Editor::AutoCompleteRequestData { { cursor().line(), cursor().column() > 0 ? cursor().column() - 1 : 0 } }; + return Editor::AutoCompleteRequestData { cursor() }; } void Editor::update_autocomplete(const AutoCompleteRequestData& data) diff --git a/DevTools/HackStudio/LanguageServers/Cpp/ClientConnection.cpp b/DevTools/HackStudio/LanguageServers/Cpp/ClientConnection.cpp index f57719f8cd3..1ce7c653183 100644 --- a/DevTools/HackStudio/LanguageServers/Cpp/ClientConnection.cpp +++ b/DevTools/HackStudio/LanguageServers/Cpp/ClientConnection.cpp @@ -159,7 +159,7 @@ void ClientConnection::handle(const Messages::LanguageServer::AutoCompleteSugges return; } - auto suggestions = AutoComplete::get_suggestions(document->text(), { (size_t)message.cursor_line(), (size_t)message.cursor_column() }); + auto suggestions = AutoComplete::get_suggestions(document->text(), { (size_t)message.cursor_line(), (size_t)max(message.cursor_column(), message.cursor_column() - 1) }); post_message(Messages::LanguageClient::AutoCompleteSuggestions(move(suggestions))); }