Repository: microsoft/terminal (language: cpp)

Issue:
[1.19 selfhost] URL autodetection is broken
Version `1.19.2371.0`, which I believe has #15858 in it.

Don't have a narrow repro yet - writing down before I forget. 

I wrote a few screenfuls of text. Then did a git push. It gave me the handy:

```
Enumerating objects: 68, done.
Counting objects: 100% (68/68), done.
Delta compression using up to 8 threads
Compressing objects: 100% (41/41), done.
Writing objects: 100% (41/41), 4.62 KiB | 2.31 MiB/s, done.
Total 41 (delta 38), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (38/38), completed with 27 local objects.
remote:
remote: Create a pull request for 'dev/migrie/f/--inherit-env-vars' on GitHub by visiting:
remote:      https://github.com/microsoft/terminal/pull/new/dev/migrie/f/--inherit-env-vars
remote:
To https://github.com/microsoft/terminal
 * [new branch]          dev/migrie/f/--inherit-env-vars -> dev/migrie/f/--inherit-env-vars
Branch 'dev/migrie/f/--inherit-env-vars' set up to track remote branch 'dev/migrie/f/--inherit-env-vars' from 'origin'.
```

But alas, a <kbd>ctrl+shift+m</kbd>,  <kbd>shift+tab</kbd> did not highlight the URL. Instead, it higlighted some text that was way up near the start of the buffer (but not like, as the same viewport-relative position or anything like that). The selected text was very much _not_ a URL:

![image](https://github.com/microsoft/terminal/assets/18356694/4ba2c9d4-e7ec-43d8-b324-d7aa43f04949)




Discussion / hints:
I have a fix on the way. 🙂

Fix patch:
diff --git a/src/cascadia/TerminalCore/Terminal.cpp b/src/cascadia/TerminalCore/Terminal.cpp
index c4e6edc2685..74f48697c86 100644
--- a/src/cascadia/TerminalCore/Terminal.cpp
+++ b/src/cascadia/TerminalCore/Terminal.cpp
@@ -1432,7 +1432,9 @@ PointTree Terminal::_getPatterns(til::CoordType beg, til::CoordType end) const
             do
             {
                 auto range = ICU::BufferRangeFromMatch(&text, re.get());
-                // PointTree uses half-open ranges.
+                // PointTree uses half-open ranges and viewport-relative coordinates.
+                range.start.y -= beg;
+                range.end.y -= beg;
                 range.end.x++;
                 intervals.push_back(PointTree::interval(range.start, range.end, 0));
             } while (uregex_findNext(re.get(), &status));


Test patch: