Fix range detection in universal locator.

This commit is contained in:
Martín Lucas Golini
2024-08-02 00:35:05 -03:00
parent d136341354
commit 5e8bfd4e66

View File

@@ -1,7 +1,7 @@
#include "universallocator.hpp"
#include "ecode.hpp"
#include "pathhelper.hpp"
#include "settingsmenu.hpp"
#include "universallocator.hpp"
#include <algorithm>
@@ -553,6 +553,10 @@ void UniversalLocator::initLocateBar( UILocateBar* locateBar, UITextInput* locat
ModelRole::Custom ) );
auto range =
rangeStr.isValid() ? TextRange::fromString( rangeStr.toString() ) : TextRange();
if ( FileSystem::isRelativePath( path ) )
path = mApp->getCurrentProject() + path;
if ( !range.isValid() && !FileSystem::isRelativePath( path ) &&
pathHasPosition( mLocateInput->getText() ) &&
String::startsWith( mLocateInput->getText().toUtf8(), path ) ) {
@@ -560,9 +564,6 @@ void UniversalLocator::initLocateBar( UILocateBar* locateBar, UITextInput* locat
range = { pathAndPos.second, pathAndPos.second };
}
if ( FileSystem::isRelativePath( path ) )
path = mApp->getCurrentProject() + path;
focusOrLoadFile( path, range );
mLocateBarLayout->execute( "close-locatebar" );
}