mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-11 04:38:24 -06:00
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:
parent
56e96c30b0
commit
60544d783b
@ -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;
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user