Skip to content

Replace New Tab Menu Match Profiles functionality with regex support #18654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 14, 2025

Conversation

carlos-zamora
Copy link
Member

@carlos-zamora carlos-zamora commented Mar 5, 2025

Summary of the Pull Request

Updates the New Tab Menu's Match Profiles entry to support regex instead of doing a direct match. Also adds validation to ensure the regex is valid. Updated the UI to help make it more clear that this supports regexes and even added a link to some helpful docs.

Validation Steps Performed

✅ Invalid regex displays a warning
✅ Valid regex works nicely
✅ profile matcher with source=Windows.Terminal.VisualStudio still works as expected

PR Checklist

Closes #18553

@microsoft-github-policy-service microsoft-github-policy-service bot added Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Area-Settings Issues related to settings and customizability, for console or terminal Product-Terminal The new Windows Terminal. labels Mar 5, 2025
@carlos-zamora
Copy link
Member Author

Demo

image

iqbalbhatti49

This comment was marked as off-topic.

@lhecker
Copy link
Member

lhecker commented Mar 16, 2025

Don't spam this repo with LLM responses. We have access to those ourselves as well. Thanks!

@DHowett DHowett marked this pull request as draft March 21, 2025 18:33
@carlos-zamora carlos-zamora marked this pull request as ready for review May 9, 2025 19:06
Comment on lines +85 to +88
UErrorCode status = U_ZERO_ERROR;
uregex_setText(regex.get(), reinterpret_cast<const UChar*>(text.data()), static_cast<int32_t>(text.size()), &status);
const auto match = uregex_matches(regex.get(), 0, &status);
return status == U_ZERO_ERROR && match;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make it easier on ourselves, we could write our own unique_uregex struct. This would allow us to define helper functions on it like matches(std::wstring_view) that does all of this under the hood for you.

Not sure if it's worth doing as part of this PR, but if you're feeling eager, I think it may be worth it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, if we do that, I think it's worth keeping the current approach of not throwing when the regex is invalid (and instead return a bool or std::optional, etc.). I feel like throwing would be overkill and just splatter try/catch everywhere we handle user input...

@carlos-zamora carlos-zamora merged commit 4d67453 into main May 14, 2025
19 checks passed
@carlos-zamora carlos-zamora deleted the dev/cazamor/ntm/matchProfile-regex branch May 14, 2025 17:30
Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix loc

return; \
} \
UErrorCode status = U_ZERO_ERROR; \
_##name##Regex = til::ICU::CreateRegex(_##name, 0, &status); \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wish "validate" didn't also mean "populate".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what i mean to say is, "i wish this was clearer about what it did"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow newTabMenu's matchProfile to work with regex
4 participants