From 735ef2823ed72d80ce91df0176646979e4568831 Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Mon, 19 Aug 2024 10:44:26 -0500 Subject: [PATCH] Restore the ability to disable checking for URLs (#17731) Fixes #17727 --- src/cascadia/TerminalCore/Terminal.cpp | 5 +++++ .../UnitTests_TerminalCore/TerminalBufferTests.cpp | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/src/cascadia/TerminalCore/Terminal.cpp b/src/cascadia/TerminalCore/Terminal.cpp index a7530807d0..87236331fc 100644 --- a/src/cascadia/TerminalCore/Terminal.cpp +++ b/src/cascadia/TerminalCore/Terminal.cpp @@ -1425,6 +1425,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; diff --git a/src/cascadia/UnitTests_TerminalCore/TerminalBufferTests.cpp b/src/cascadia/UnitTests_TerminalCore/TerminalBufferTests.cpp index 827c4da85c..ac9841369d 100644 --- a/src/cascadia/UnitTests_TerminalCore/TerminalBufferTests.cpp +++ b/src/cascadia/UnitTests_TerminalCore/TerminalBufferTests.cpp @@ -607,6 +607,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();