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

Add openTabRenamer action #7462

Merged
9 commits merged into from
Oct 28, 2020
Merged

Add openTabRenamer action #7462

9 commits merged into from
Oct 28, 2020

Conversation

Coridyn
Copy link
Contributor

@Coridyn Coridyn commented Aug 29, 2020

Adds a ShortcutAction to allow editing the tab title via the TextBox
(just like double-clicking the tab, but triggered from a key binding or
command palette).

Related to #6256 (but doesn't address pane renaming)

@Coridyn
Copy link
Contributor Author

Coridyn commented Aug 29, 2020

Sorry, there are two items that I don't know how to address:

  1. Cannot trigger tab renaming from the command palette because the "enter" keyup event from the palette is also sent to the edit textbox, closing it immediately
  • Steps to replicate:
    • open command palette (Ctrl+Shift+P)
    • search for "rename" and highlight the new "Rename tab title..." action
    • hit enter to activate the tab rename action
    • note that the rename textbox is shown but then immediately removed because it receives the "enter" event from the command palette
  1. Focus is set to the "New Tab" button after the rename textbox is removed (either by hitting enter or escape)
  • it would be nice to have focus return back to the console
  • I've noted this same behaviour also happens when the rename was triggered by double-clicking on the tab title, so it might be out of scope of this item and should be handled in its own issue?

For item 1 the only thing I can think of is to add a KeyDown listener and flag variable so we only process the KeyUp event if it was preceded by a KeyDown, something like this:

// We'll only process KeyUp event if `receivedKeyDown` is true
auto receivedKeyDown = false;
tabTextBox.KeyDown([&receivedKeyDown](const IInspectable&, Input::KeyRoutedEventArgs const&) {
    receivedKeyDown = true;
});

tabTextBox.KeyUp([weakThis, &receivedKeyDown](const IInspectable& sender, Input::KeyRoutedEventArgs const& e) {
    auto tab{ weakThis.get() };
    auto textBox{ sender.try_as<Controls::TextBox>() };
    if (tab && textBox && receivedKeyDown)
    {
        // ...
    }

    receivedKeyDown = false;
});

But that doesn't seem very nice.

Otherwise, is there is some way to only add the tabTextBox to the tabViewItem after the KeyUp has been processed, or to know which control raised the KeyUp event?

@zadjii-msft zadjii-msft self-assigned this Oct 1, 2020
@zadjii-msft
Copy link
Member

Hey sorry, just getting back from leave now and catching up on older PRs. As far as the focus issues are concerned, you've stumbled into one of the horrible bug factories of this project I'm afraid 😬 See #6680 for more details.

Your proposed solution to issue 1 seems sensible to me. A bit hacky, but everything we're doing with focus is a tad bit hacky, and that doesn't seem any worse. I'm a tad bit worried about receivedKeyDown being a stack variable - I think it'll work fine if we make that a member of Tab instead, and reset it when the renamer is first opened.

As far as issue 2 goes, since that's already existing behavior, I wouldn't worry about it too much during this PR. we can always punt that to a future bugfix.

Other than that, there have been some settings changes recently, so you'll need to do a merge from master, but it should just be re-namespacing things.

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

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

Other than doing that keyup thing you mentioned earlier, and merging with master, the rest of this looks great!

@zadjii-msft zadjii-msft assigned Coridyn and unassigned zadjii-msft Oct 13, 2020
@zadjii-msft zadjii-msft added Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Oct 13, 2020
@ghost ghost added the No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity. label Oct 20, 2020
@ghost
Copy link

ghost commented Oct 20, 2020

This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 7 days of this comment.

@Coridyn
Copy link
Contributor Author

Coridyn commented Oct 20, 2020

Thanks for the feedback on this.

I'll make receivedKeyDown a member variable and see how it goes - you're right it didn't work as a stack variable 😅

@ghost ghost removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity. labels Oct 20, 2020
@github-actions
Copy link

New misspellings found, please review:

  • Renamer
To accept these changes, run the following commands
perl -e '
my @expect_files=qw('".github/actions/spell-check/expect/alphabet.txt
.github/actions/spell-check/expect/expect.txt
.github/actions/spell-check/expect/web.txt"');
@ARGV=@expect_files;
my @stale=qw('"akb appdata Autogenerated autologin CParams cppcorecheck debian debugbreak decf DECLL DECSMBV esa FILEPATH guidgenerator hhhh Inplace keith keybound naws notypeopt openlogo restrictederrorinfo rgus richturn Scs SGRXY subnegotiation Switchto telnetpp winver Wlk wslhome xe "');
my $re=join "|", @stale;
my $suffix=".".time();
my $previous="";
sub maybe_unlink { unlink($_[0]) if $_[0]; }
while (<>) {
  if ($ARGV ne $old_argv) { maybe_unlink($previous); $previous="$ARGV$suffix"; rename($ARGV, $previous); open(ARGV_OUT, ">$ARGV"); select(ARGV_OUT); $old_argv = $ARGV; }
  next if /^($re)(?:$| .*)/; print;
}; maybe_unlink($previous);'
perl -e '
my $new_expect_file=".github/actions/spell-check/expect/2e0d00bb420b70f60590b73c3b634374eb2bebd6.txt";
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"autogenerated CPPCORECHECK Debian filepath inplace Renamer WINVER "');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a) cmp lc($b)} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;'
git add .github/actions/spell-check/expect || echo '... you want to ensure .github/actions/spell-check/expect/2e0d00bb420b70f60590b73c3b634374eb2bebd6.txt is added to your repository...'
✏️ Contributor please read this

By default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.

⚠️ The command is written for posix shells. You can copy the contents of each perl command excluding the outer ' marks and dropping any '"/"' quotation mark pairs into a file and then run perl file.pl from the root of the repository to run the code. Alternatively, you can manually insert the items...

If the listed items are:

  • ... misspelled, then please correct them instead of using the command.
  • ... names, please add them to .github/actions/spell-check/dictionary/names.txt.
  • ... APIs, you can add them to a file in .github/actions/spell-check/dictionary/.
  • ... just things you're using, please add them to an appropriate file in .github/actions/spell-check/expect/.
  • ... tokens you only need in one place and shouldn't generally be used, you can add an item in an appropriate file in .github/actions/spell-check/patterns/.

See the README.md in each directory for more information.

🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The :check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉

⚠️ Reviewers

At present, the action that triggered this message will not show its ❌ in this PR unless the branch is within this repository.
Thus, you should make sure that this comment has been addressed before encouraging the merge bot to merge this PR.

@zadjii-msft zadjii-msft assigned zadjii-msft and unassigned Coridyn Oct 21, 2020
@microsoft-github-updates microsoft-github-updates bot changed the base branch from master to main October 22, 2020 00:27
@Coridyn Coridyn marked this pull request as ready for review October 22, 2020 05:01
@Coridyn
Copy link
Contributor Author

Coridyn commented Oct 22, 2020

This has been rebased onto main and I've been able to try it out locally.

Implementing the _receivedKeyDown flag has fixed the issue with the text box closing immediately from the command palette.

@zadjii-msft
Copy link
Member

@Coridyn Thanks! I'll try and take a look at this tomorrow morning. In the meantime, don't worry about the linter error - it's being a tad aggressive and we're still trying to figure out the right balance here. We'll probably push an update to main that disables the json linting, so just hang tight ☺️
/cc @DHowett who might be able to disable the linter while I'm out today

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

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

This looks good to me, thanks for throwing this together!

@zadjii-msft zadjii-msft removed their assignment Oct 28, 2020
@zadjii-msft zadjii-msft added the Needs-Second It's a PR that needs another sign-off label Oct 28, 2020
@zadjii-msft
Copy link
Member

Oh hey don't worry about the linter error - that's just the linter being a little over-zealous while we calibrate it the way we'd like. I'll take care of that.

DHowett pushed a commit that referenced this pull request Oct 28, 2020
All our JSON files are _actually_ JSONC files - json with comments. 

A well-behaved application that accepts JSON should accept and ignore
comments. However, `jsonlint` is not a well behaved application in this
regard.

So, to prevent the linter from complaining about our JSON comments, we
need to disable it entirely. THAT'S RIGHT, there's not a setting to
allow JSONC. 

See #8076 as an example of this working.

This will also unblock #7462.
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.

This is lovely. Thanks for working on it, and sorry we took forever to review it!

@zadjii-msft
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@zadjii-msft zadjii-msft added the AutoMerge Marked for automatic merge by the bot when requirements are met label Oct 28, 2020
@ghost
Copy link

ghost commented Oct 28, 2020

Hello @zadjii-msft!

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 8e3f27f into microsoft:main Oct 28, 2020
@yasintz
Copy link

yasintz commented Oct 28, 2020

👏 👏

@Coridyn
Copy link
Contributor Author

Coridyn commented Oct 29, 2020

Awesome, thanks for your help @zadjii-msft and @DHowett!

@ghost
Copy link

ghost commented Nov 11, 2020

🎉Windows Terminal Preview v1.5.3142.0 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 Issue-Task It's a feature request, but it doesn't really need a major design. Needs-Second It's a PR that needs another sign-off Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants