mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-10-27 08:37:58 +03:00
Prevent a crash when signature parameters are incorrect.
"About ecode" close with escape (SpartanJ/ecode#873).
This commit is contained in:
@@ -474,10 +474,6 @@
|
||||
"name": "nvidia/nemotron-3-super-120b-a12b:free",
|
||||
"display_name": "NVIDIA: Nemotron 3 Super (free)"
|
||||
},
|
||||
{
|
||||
"name": "qwen/qwen3.6-plus:free",
|
||||
"display_name": "Qwen: Qwen3.6 Plus (free)"
|
||||
},
|
||||
{
|
||||
"name": "minimax/minimax-m2.5:free",
|
||||
"display_name": "MiniMax: MiniMax M2.5 (free)"
|
||||
|
||||
@@ -620,6 +620,9 @@ class EE_API TextDocument {
|
||||
|
||||
TextRange addSelections( TextRanges&& selections );
|
||||
|
||||
/* @return returns the selection index otherwise -1 */
|
||||
int selectionIndex( TextRange selection ) const;
|
||||
|
||||
void popSelection();
|
||||
|
||||
bool deleteSelection( const size_t& cursorIdx );
|
||||
|
||||
@@ -1288,6 +1288,15 @@ TextRange TextDocument::addSelection( TextRange selection ) {
|
||||
return selection;
|
||||
}
|
||||
|
||||
int TextDocument::selectionIndex( TextRange selection ) const {
|
||||
if ( mSelection.exists( selection ) )
|
||||
return mSelection.findIndex( selection );
|
||||
selection = sanitizeRange( selection );
|
||||
if ( mSelection.exists( selection ) )
|
||||
return mSelection.findIndex( selection );
|
||||
return -1;
|
||||
}
|
||||
|
||||
void TextDocument::popSelection() {
|
||||
mSelection.pop_back();
|
||||
if ( mLastSelection >= mSelection.size() )
|
||||
|
||||
@@ -857,18 +857,24 @@ AutoCompletePlugin::processSignatureHelp( const LSPSignatureHelp& signatureHelp
|
||||
doc.textInput( initialLabel );
|
||||
std::vector<String> parameters;
|
||||
parameters.reserve( sig.parameters.size() );
|
||||
int skippedSelections = 0;
|
||||
|
||||
for ( size_t i = 0; i < sig.parameters.size(); i++ ) {
|
||||
auto start = String::utf8ToCodepointPosition( sig.label, sig.parameters[i].start );
|
||||
auto end = String::utf8ToCodepointPosition( sig.label, sig.parameters[i].end );
|
||||
auto sel = TextRange::convertToLineColumn( initialLabel.view(), start, end );
|
||||
size_t index = i - skippedSelections;
|
||||
|
||||
if ( i == 0 )
|
||||
if ( i == 0 ) {
|
||||
doc.setSelection( i, sel );
|
||||
else
|
||||
doc.addSelection( sel );
|
||||
} else {
|
||||
if ( !doc.addSelection( sel ).isValid() ) {
|
||||
skippedSelections++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
parameters.emplace_back( doc.getSelectedText( i ) );
|
||||
parameters.emplace_back( doc.getSelectedText( index ) );
|
||||
}
|
||||
|
||||
auto selections( doc.getSelections() );
|
||||
|
||||
@@ -131,6 +131,7 @@ void SettingsActions::aboutEcode() {
|
||||
image->setSize( { 128, 128 } );
|
||||
image->toBack();
|
||||
msgBox->setTitle( i18n( "about_ecode", "About ecode..." ) );
|
||||
msgBox->setCloseShortcut( { KEY_ESCAPE, 0 } );
|
||||
msgBox->showWhenReady();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user