| 555 | } |
| 556 | |
| 557 | bool AutoCompletePlugin::onTextInput( UICodeEditor* editor, const TextInputEvent& event ) { |
| 558 | std::string partialSymbol( getPartialSymbol( &editor->getDocument() ) ); |
| 559 | |
| 560 | auto lang = editor->getDocumentRef()->getSyntaxDefinition().getLSPName(); |
| 561 | auto cap = mCapabilities.find( lang ); |
| 562 | if ( cap != mCapabilities.end() ) { |
| 563 | if ( cap->second.signatureHelpProvider.provider ) { |
| 564 | bool requestedSignatureHelp = false; |
| 565 | const auto& signatureTrigger = cap->second.signatureHelpProvider.triggerCharacters; |
| 566 | if ( std::find( signatureTrigger.begin(), signatureTrigger.end(), event.getChar() ) != |
| 567 | signatureTrigger.end() ) { |
| 568 | requestSignatureHelp( editor ); |
| 569 | requestedSignatureHelp = true; |
| 570 | } |
| 571 | if ( mSignatureHelpVisible && !requestedSignatureHelp ) { |
| 572 | auto doc = editor->getDocumentRef(); |
| 573 | auto curPos = doc->getSelection().start(); |
| 574 | if ( curPos.line() != mSignatureHelpPosition.line() || |
| 575 | curPos < doc->startOfWord( doc->positionOffset( mSignatureHelpPosition, 1 ) ) ) |
| 576 | resetSignatureHelp(); |
| 577 | } |
| 578 | } |
| 579 | |
| 580 | if ( cap->second.completionProvider.provider ) { |
| 581 | const auto& triggerCharacters = cap->second.completionProvider.triggerCharacters; |
| 582 | if ( partialSymbol.size() >= 1 || |
| 583 | std::find( triggerCharacters.begin(), triggerCharacters.end(), event.getChar() ) != |
| 584 | triggerCharacters.end() ) { |
| 585 | updateSuggestions( partialSymbol, editor ); |
| 586 | } else { |
| 587 | resetSuggestions( editor ); |
| 588 | } |
| 589 | } |
| 590 | return false; |
| 591 | } |
| 592 | |
| 593 | if ( partialSymbol.size() >= 3 ) { |
| 594 | updateSuggestions( partialSymbol, editor ); |
| 595 | } else { |
| 596 | resetSuggestions( editor ); |
| 597 | } |
| 598 | return false; |
| 599 | } |
| 600 | |
| 601 | void AutoCompletePlugin::updateDocCache( TextDocument* doc ) { |
| 602 | ScopedOp op( |
no test coverage detected