mirror of
https://github.com/MaskRay/ccls.git
synced 2025-01-19 03:55:49 +00:00
Fix signatureHelp signature selection heuristic
This commit is contained in:
parent
c36eda70f9
commit
8c6a87b3a3
@ -4,6 +4,8 @@
|
|||||||
#include "queue_manager.h"
|
#include "queue_manager.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct Ipc_TextDocumentSignatureHelp
|
struct Ipc_TextDocumentSignatureHelp
|
||||||
: public RequestMessage<Ipc_TextDocumentSignatureHelp> {
|
: public RequestMessage<Ipc_TextDocumentSignatureHelp> {
|
||||||
@ -122,13 +124,17 @@ struct TextDocumentSignatureHelpHandler : MessageHandler {
|
|||||||
out.result.signatures.push_back(signature);
|
out.result.signatures.push_back(signature);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Guess the signature the user wants based on available parameter
|
// Prefer the signature with least parameter count but still larger
|
||||||
// count.
|
// than active_param.
|
||||||
out.result.activeSignature = 0;
|
out.result.activeSignature = 0;
|
||||||
for (size_t i = 0; i < out.result.signatures.size(); ++i) {
|
if (out.result.signatures.size()) {
|
||||||
if (active_param < out.result.signatures.size()) {
|
size_t num_parameters = SIZE_MAX;
|
||||||
out.result.activeSignature = (int)i;
|
for (size_t i = 0; i < out.result.signatures.size(); ++i) {
|
||||||
break;
|
size_t t = out.result.signatures[i].parameters.size();
|
||||||
|
if (active_param < t && t < num_parameters) {
|
||||||
|
out.result.activeSignature = int(i);
|
||||||
|
num_parameters = t;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user