Skip to content
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

Polish MarkMode interactions with ExpandSelectionToWord and existing selection #13893

Merged
3 commits merged into from
Sep 7, 2022

Conversation

carlos-zamora
Copy link
Member

@carlos-zamora carlos-zamora commented Aug 31, 2022

  • fix: if a selection exists, mark mode should promote the existing selection instead of creating one at the cursor
  • fix: mark mode --> move to middle of a word --> ExpandSelectionToWord --> Shift+Right/Left had some weird behavior. Fix that
  • fix: Ctrl+enter on random selection clears selection. It should try to treat selection as a URL.

References

#13854

NOTE: 3b53f3c can be serviced

_selection->end = buffer.GetWordEnd(_selection->end, _wordDelimiters);

// if we're targetting both endpoints, instead just target "end"
if (WI_IsFlagSet(_selectionEndpoint, SelectionEndpoint::Start) && WI_IsFlagSet(_selectionEndpoint, SelectionEndpoint::End))
Copy link
Member

Choose a reason for hiding this comment

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

👉 WI_AreAllFlagsSet

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried 😭. Compiler gave me sass about & not being defined or something like that even though this is at the top of the file:
DEFINE_ENUM_FLAG_OPERATORS(Terminal::SelectionEndpoint);

Copy link
Member

Choose a reason for hiding this comment

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

Huh... that's weird. We do use WI_AreAllFlagsSet in TermControl.cpp already.

Copy link
Member

Choose a reason for hiding this comment

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

with this specific enum type? If so, yes, thisd should work. If not, we probably need the DECLARE_ENUM_BOOLEAN_VALUES thing...

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah :(

DEFINE_ENUM_FLAG_OPERATORS(Terminal::SelectionEndpoint);

I'm curious. Imma try that declare enum bool thing.

Copy link
Member Author

Choose a reason for hiding this comment

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

ugh, yeah I can't find that macro. We'll figure it out later.

Copy link
Member

Choose a reason for hiding this comment

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

It's maddening that WI_AreAllFlagsClear works perfectly well nary 20 lines above.

Copy link
Member

Choose a reason for hiding this comment

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

SIMILAR: microsoft/wil#45

Copy link
Member

Choose a reason for hiding this comment

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

This is likely because of ADL failing on our nested type ;P

@carlos-zamora carlos-zamora force-pushed the dev/cazamor/sln-polish branch from 5674123 to 85b219a Compare August 31, 2022 23:55
@carlos-zamora carlos-zamora added this to the Terminal v1.16 milestone Aug 31, 2022
@carlos-zamora
Copy link
Member Author

@lhecker added a fix for...

Ctrl+enter on random selection clears selection. Maybe it should try to treat selection as a URL?

Shouldn't be controversial but feel free to disagree haha

@DHowett
Copy link
Member

DHowett commented Sep 1, 2022

NOTE: 3b53f3c can be serviced

FYI: Using individual commits makes it somewhat difficult because they require manual cherry picking and can't go through the script. No need to change right now, but just for the future :)

@DHowett
Copy link
Member

DHowett commented Sep 1, 2022

DEFINE_ENUM_FLAG_OPERATORS

else
{
const auto selectedText = _terminal->GetTextBuffer().GetPlainText(_terminal->GetSelectionAnchor(), _terminal->GetSelectionEnd());
_OpenHyperlinkHandlers(*this, winrt::make<OpenHyperlinkEventArgs>(winrt::hstring{ selectedText }));
Copy link
Member

Choose a reason for hiding this comment

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

isn't this just gonna cause a crash later when it turns out that the thing isn't a hyperlink?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, we have logic somewhere such that a popup appears saying that it's not a hyperlink (I'll pull up a pic and attach it here later).

I'm pretty sure it's localized too. I'm just using what we have hahaha.

Copy link
Member Author

Choose a reason for hiding this comment

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

dialog box saying 'this link is invalid' and injecting the selected text into it'

@@ -517,11 +533,6 @@ void Terminal::SelectHyperlink(const SearchDirection dir)
_ScrollToPoint(_selection->end);
}

bool Terminal::SelectionIsTargetingUrl() const noexcept
{
return _selectionIsTargetingUrl;
Copy link
Member

Choose a reason for hiding this comment

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

so _selectionIsTargetingUrl is now only used to know whether we are in URL jump mode?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, it's only so that we don't jump to the link we just jumped to when moving forward?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup. It's so that we skip over the one that's currently selected.

@DHowett DHowett added the AutoMerge Marked for automatic merge by the bot when requirements are met label Sep 7, 2022
@ghost
Copy link

ghost commented Sep 7, 2022

Hello @DHowett!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 1ef4a42 into main Sep 7, 2022
@ghost ghost deleted the dev/cazamor/sln-polish branch September 7, 2022 16:07
@ghost
Copy link

ghost commented Sep 13, 2022

🎉Windows Terminal v1.15.252 has been released which incorporates this pull request.:tada:

Handy links:

@ghost
Copy link

ghost commented Sep 13, 2022

🎉Windows Terminal Preview v1.16.252 has been released which incorporates this pull request.:tada:

Handy links:

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AutoMerge Marked for automatic merge by the bot when requirements are met
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants