From 98d7ec00b5cfba14a8d2707b32aea61c2894f668 Mon Sep 17 00:00:00 2001 From: TerminalFi Date: Fri, 31 Mar 2023 12:15:40 -0500 Subject: [PATCH 1/3] adding support for optional col with `:` separator --- src/tools/ecode/universallocator.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/tools/ecode/universallocator.cpp b/src/tools/ecode/universallocator.cpp index 1fbcb0f8b..c29c32558 100644 --- a/src/tools/ecode/universallocator.cpp +++ b/src/tools/ecode/universallocator.cpp @@ -227,11 +227,20 @@ void UniversalLocator::initLocateBar( UILocateBar* locateBar, UITextInput* locat mLocateInput->addEventListener( Event::OnTextChanged, [&]( const Event* ) { const String& txt = mLocateInput->getText(); if ( mSplitter->curEditorExistsAndFocused() && String::startsWith( txt, String( "l " ) ) ) { - String number( txt.substr( 2 ) ); - Int64 val; - if ( String::fromString( val, number ) && val - 1 >= 0 ) { - if ( mSplitter->curEditorExistsAndFocused() ) - mSplitter->getCurEditor()->goToLine( { val - 1, 0 } ); + String txtSubstring( txt.substr( 2 ) ); + std::vector parts = txtSubstring.split( ':' ); + Int64 line, column = 0; + + if ( parts.size() > 0 && String::fromString( line, parts[0] ) && line - 1 >= 0 ) { + if ( parts.size() > 1 ) { + String::fromString( column, parts[1] ); + if ( column < 0 ) { + column = 0; + } + } + if ( mSplitter->curEditorExistsAndFocused() ) { + mSplitter->getCurEditor()->goToLine( { line - 1, column } ); + } mLocateTable->setVisible( false ); } } else if ( !txt.empty() && mLocateInput->getText()[0] == '>' ) { From 803ceab5e1357ed93a08b17853ab90ba5bf02d42 Mon Sep 17 00:00:00 2001 From: TerminalFi Date: Fri, 31 Mar 2023 12:17:29 -0500 Subject: [PATCH 2/3] rename var to input --- src/tools/ecode/universallocator.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/tools/ecode/universallocator.cpp b/src/tools/ecode/universallocator.cpp index c29c32558..8f9535375 100644 --- a/src/tools/ecode/universallocator.cpp +++ b/src/tools/ecode/universallocator.cpp @@ -225,10 +225,11 @@ void UniversalLocator::initLocateBar( UILocateBar* locateBar, UITextInput* locat mLocateTable->setHeadersVisible( false ); mLocateTable->setVisible( false ); mLocateInput->addEventListener( Event::OnTextChanged, [&]( const Event* ) { - const String& txt = mLocateInput->getText(); - if ( mSplitter->curEditorExistsAndFocused() && String::startsWith( txt, String( "l " ) ) ) { - String txtSubstring( txt.substr( 2 ) ); - std::vector parts = txtSubstring.split( ':' ); + const String& input = mLocateInput->getText(); + if ( mSplitter->curEditorExistsAndFocused() && + String::startsWith( input, String( "l " ) ) ) { + String lineColInput( input.substr( 2 ) ); + std::vector parts = lineColInput.split( ':' ); Int64 line, column = 0; if ( parts.size() > 0 && String::fromString( line, parts[0] ) && line - 1 >= 0 ) { @@ -243,11 +244,11 @@ void UniversalLocator::initLocateBar( UILocateBar* locateBar, UITextInput* locat } mLocateTable->setVisible( false ); } - } else if ( !txt.empty() && mLocateInput->getText()[0] == '>' ) { + } else if ( !input.empty() && mLocateInput->getText()[0] == '>' ) { showCommandPalette(); - } else if ( !txt.empty() && mLocateInput->getText()[0] == ':' ) { + } else if ( !input.empty() && mLocateInput->getText()[0] == ':' ) { showWorkspaceSymbol(); - } else if ( String::startsWith( txt, ". " ) ) { + } else if ( String::startsWith( input, ". " ) ) { showDocumentSymbol(); } else { showLocateTable(); From a44a6b829a508495e7b3bdd11642049c812579e1 Mon Sep 17 00:00:00 2001 From: TerminalFi Date: Fri, 31 Mar 2023 12:19:18 -0500 Subject: [PATCH 3/3] rename to inputTxt --- src/tools/ecode/universallocator.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/tools/ecode/universallocator.cpp b/src/tools/ecode/universallocator.cpp index 8f9535375..e65a8712f 100644 --- a/src/tools/ecode/universallocator.cpp +++ b/src/tools/ecode/universallocator.cpp @@ -225,10 +225,10 @@ void UniversalLocator::initLocateBar( UILocateBar* locateBar, UITextInput* locat mLocateTable->setHeadersVisible( false ); mLocateTable->setVisible( false ); mLocateInput->addEventListener( Event::OnTextChanged, [&]( const Event* ) { - const String& input = mLocateInput->getText(); + const String& inputTxt = mLocateInput->getText(); if ( mSplitter->curEditorExistsAndFocused() && - String::startsWith( input, String( "l " ) ) ) { - String lineColInput( input.substr( 2 ) ); + String::startsWith( inputTxt, String( "l " ) ) ) { + String lineColInput( inputTxt.substr( 2 ) ); std::vector parts = lineColInput.split( ':' ); Int64 line, column = 0; @@ -244,11 +244,11 @@ void UniversalLocator::initLocateBar( UILocateBar* locateBar, UITextInput* locat } mLocateTable->setVisible( false ); } - } else if ( !input.empty() && mLocateInput->getText()[0] == '>' ) { + } else if ( !inputTxt.empty() && mLocateInput->getText()[0] == '>' ) { showCommandPalette(); - } else if ( !input.empty() && mLocateInput->getText()[0] == ':' ) { + } else if ( !inputTxt.empty() && mLocateInput->getText()[0] == ':' ) { showWorkspaceSymbol(); - } else if ( String::startsWith( input, ". " ) ) { + } else if ( String::startsWith( inputTxt, ". " ) ) { showDocumentSymbol(); } else { showLocateTable();