Prevent a crash when signature parameters are incorrect.

"About ecode" close with escape (SpartanJ/ecode#873).
This commit is contained in:
Martín Lucas Golini
2026-04-08 15:51:35 -03:00
parent f72b1c2f13
commit 57929621df
5 changed files with 23 additions and 8 deletions
-4
View File
@@ -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)"
+3
View File
@@ -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 );
+9
View File
@@ -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() );
+1
View File
@@ -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();
}