Restore the ability to disable checking for URLs (#17731)

Fixes #17727

(cherry picked from commit 735ef2823ed72d80ce91df0176646979e4568831)
Service-Card-Id: 93736212
Service-Version: 1.20
This commit is contained in:
Dustin L. Howett 2024-08-19 10:44:26 -05:00 committed by Dustin Howett
parent 56e96c30b0
commit 60544d783b
2 changed files with 12 additions and 0 deletions

View File

@ -1405,6 +1405,11 @@ PointTree Terminal::_getPatterns(til::CoordType beg, til::CoordType end) const
LR"(\b(?:https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|$!:,.;]*[A-Za-z0-9+&@#/%=~_|$])",
};
if (!_detectURLs)
{
return {};
}
auto text = ICU::UTextFromTextBuffer(_activeBuffer(), beg, end + 1);
UErrorCode status = U_ZERO_ERROR;
PointTree::interval_vector intervals;

View File

@ -649,6 +649,13 @@ void TerminalBufferTests::TestURLPatternDetection()
constexpr auto urlStartX = BeforeStr.size();
constexpr auto urlEndX = BeforeStr.size() + UrlStr.size() - 1;
// This is off by default; turn it on for the test.
auto originalDetectURLs = term->_detectURLs;
auto restoreDetectUrls = wil::scope_exit([&]() {
term->_detectURLs = originalDetectURLs;
});
term->_detectURLs = true;
auto& termSm = *term->_stateMachine;
termSm.ProcessString(fmt::format(FMT_COMPILE(L"{}{}{}"), BeforeStr, UrlStr, AfterStr));
term->UpdatePatternsUnderLock();