Fixed auto close bracket selection in ecode.

Added swift lang support.
This commit is contained in:
Martín Lucas Golini
2020-08-26 01:50:40 -03:00
parent e52924c983
commit e57b8d1a56
2 changed files with 224 additions and 2 deletions

View File

@@ -1366,14 +1366,16 @@ UIMenu* App::createDocumentMenu() {
->setOnShouldCloseCb( shouldCloseCb )
->setId( "``" );
bracketsMenu->addEventListener( Event::OnItemClicked, [&]( const Event* event ) {
const String& id = event->getNode()->getId();
std::string id = event->getNode()->getId();
if ( event->getNode()->isType( UI_TYPE_MENUCHECKBOX ) ) {
UIMenuCheckBox* item = event->getNode()->asType<UIMenuCheckBox>();
auto curPairs = String::split( mConfig.editor.autoCloseBrackets, ',' );
auto found = std::find( curPairs.begin(), curPairs.end(), id );
if ( item->isActive() ) {
auto found = std::find( curPairs.begin(), curPairs.end(), id );
if ( found == curPairs.end() )
curPairs.push_back( id );
} else if ( found != curPairs.end() ) {
curPairs.erase( found );
}
mConfig.editor.autoCloseBrackets = String::join( curPairs, ',' );
auto pairs = makeAutoClosePairs( mConfig.editor.autoCloseBrackets );