Skip to content

Commit

Permalink
final cleanup for review
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Mar 1, 2023
1 parent 173a830 commit 20f5651
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 57 deletions.
4 changes: 1 addition & 3 deletions .github/actions/spelling/allow/allow.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,8 @@ shcha
slnt
Sos
ssh
<<<<<<< HEAD
=======
stakeholders
>>>>>>> main
sxn
timeline
timelines
timestamped
Expand Down
4 changes: 0 additions & 4 deletions src/cascadia/TerminalApp/ActionPreviewHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,6 @@ namespace winrt::TerminalApp::implementation
const auto backup = _restorePreviewFuncs.empty();

_ApplyToActiveControls([&](const auto& control) {
// // Stash a copy of the original opacity.
// auto originalOpacity{ control.BackgroundOpacity() };

// Apply the new opacity
control.PreviewInput(args.Input());

if (backup)
Expand Down
30 changes: 11 additions & 19 deletions src/cascadia/TerminalApp/SuggestionsControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,6 @@ namespace winrt::TerminalApp::implementation
void SuggestionsControl::_selectedCommandChanged(const IInspectable& /*sender*/,
const Windows::UI::Xaml::RoutedEventArgs& /*args*/)
{
// const auto currentlyVisible{ Visibility() == Visibility::Visible };

const auto selectedCommand = _filteredActionsView().SelectedItem();
const auto filteredCommand{ selectedCommand.try_as<winrt::TerminalApp::FilteredCommand>() };

Expand All @@ -277,11 +275,8 @@ namespace winrt::TerminalApp::implementation
const Windows::UI::Xaml::Input::KeyRoutedEventArgs& e)
{
const auto key = e.OriginalKey();
// const auto scanCode = e.KeyStatus().ScanCode;
const auto coreWindow = CoreWindow::GetForCurrentThread();
const auto ctrlDown = WI_IsFlagSet(coreWindow.GetKeyState(winrt::Windows::System::VirtualKey::Control), CoreVirtualKeyStates::Down);
// const auto altDown = WI_IsFlagSet(coreWindow.GetKeyState(winrt::Windows::System::VirtualKey::Menu), CoreVirtualKeyStates::Down);
// const auto shiftDown = WI_IsFlagSet(coreWindow.GetKeyState(winrt::Windows::System::VirtualKey::Shift), CoreVirtualKeyStates::Down);

if (key == VirtualKey::Home && ctrlDown)
{
Expand All @@ -295,32 +290,36 @@ namespace winrt::TerminalApp::implementation
}
else if (key == VirtualKey::Up)
{
// Action Mode: Move focus to the next item in the list.
// Move focus to the next item in the list.
SelectNextItem(false);
e.Handled(true);
}
else if (key == VirtualKey::Down)
{
// Action Mode: Move focus to the previous item in the list.
// Move focus to the previous item in the list.
SelectNextItem(true);
e.Handled(true);
}
else if (key == VirtualKey::PageUp)
{
// Action Mode: Move focus to the first visible item in the list.
// Move focus to the first visible item in the list.
ScrollPageUp();
e.Handled(true);
}
else if (key == VirtualKey::PageDown)
{
// Action Mode: Move focus to the last visible item in the list.
// Move focus to the last visible item in the list.
ScrollPageDown();
e.Handled(true);
}
else if (key == VirtualKey::Enter ||
key == VirtualKey::Tab ||
key == VirtualKey::Right)
{
// If the user pressed enter, tab, or the right arrow key, then
// we'll want to dispatch the command that's selected as they
// accepted the suggestion.

if (const auto& button = e.OriginalSource().try_as<Button>())
{
// Let the button handle the Enter key so an eventually attached click handler will be called
Expand Down Expand Up @@ -482,9 +481,6 @@ namespace winrt::TerminalApp::implementation

void SuggestionsControl::_listItemSelectionChanged(const Windows::Foundation::IInspectable& /*sender*/, const Windows::UI::Xaml::Controls::SelectionChangedEventArgs& e)
{
// We don't care about...
// - CommandlineMode: it doesn't have any selectable items in the list view
// - TabSwitchMode: focus and selected item are in sync
if (auto automationPeer{ Automation::Peers::FrameworkElementAutomationPeer::FromElement(_searchBox()) })
{
if (const auto selectedList = e.AddedItems(); selectedList.Size() > 0)
Expand All @@ -498,7 +494,7 @@ namespace winrt::TerminalApp::implementation
Automation::Peers::AutomationNotificationKind::ItemAdded,
Automation::Peers::AutomationNotificationProcessing::MostRecent,
paletteItem.Name() + L" " + paletteItem.KeyChordText(),
L"CommandPaletteSelectedItemChanged" /* unique name for this notification category */);
L"SuggestionsControlSelectedItemChanged" /* unique name for this notification category */);
}
}
}
Expand Down Expand Up @@ -574,7 +570,7 @@ namespace winrt::TerminalApp::implementation
Automation::Peers::AutomationNotificationKind::ActionCompleted,
Automation::Peers::AutomationNotificationProcessing::CurrentThenMostRecent,
fmt::format(std::wstring_view{ RS_(L"CommandPalette_NestedCommandAnnouncement") }, ParentCommandName()),
L"CommandPaletteNestingLevelChanged" /* unique name for this notification category */);
L"SuggestionsControlNestingLevelChanged" /* unique name for this notification category */);
}
}

Expand Down Expand Up @@ -798,7 +794,6 @@ namespace winrt::TerminalApp::implementation
SearchBoxPlaceholderText(RS_(L"CommandPalette_SearchBox/PlaceholderText"));
NoMatchesText(RS_(L"CommandPalette_NoMatchesText/Text"));
ControlName(RS_(L"CommandPaletteControlName"));
// PrefixCharacter(L">");
// modeAnnouncementResourceKey is already set to _ActionMode
// We did this above to deduce the type (and make it easier on ourselves later).

Expand Down Expand Up @@ -950,9 +945,6 @@ namespace winrt::TerminalApp::implementation

_PreviewActionHandlers(*this, nullptr);

// // Reset visibility in case anchor mode tab switcher just finished.
// _searchBox().Visibility(Visibility::Visible);

// Clear the text box each time we close the dialog. This is consistent with VsCode.
_searchBox().Text(L"");

Expand Down Expand Up @@ -1089,7 +1081,7 @@ namespace winrt::TerminalApp::implementation
}
else
{
// Position at the cursor. The suggestions UI itself will maintian
// Position at the cursor. The suggestions UI itself will maintain
// its own offset such that it's always above its origin
newMargin.Top = (_anchor.Y - actualSize.height);
}
Expand Down
9 changes: 4 additions & 5 deletions src/cascadia/TerminalControl/ControlCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2096,12 +2096,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
}
}

void ControlCore::_terminalMenuChanged(std::wstring_view menuJson, int32_t replaceLength)
void ControlCore::_terminalMenuChanged(std::wstring_view menuJson,
int32_t replaceLength)
{
// _updateMenu->Run(winrt::hstring{ menuJson }, replaceLength);
// _MenuChangedHandlers(*this, nullptr);

auto args = winrt::make_self<MenuChangedEventArgs>(winrt::hstring{ menuJson }, replaceLength);
auto args = winrt::make_self<MenuChangedEventArgs>(winrt::hstring{ menuJson },
replaceLength);
_MenuChangedHandlers(*this, *args);
}

Expand Down
1 change: 0 additions & 1 deletion src/cascadia/TerminalControl/TSFInputControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation
Canvas().Visibility(text.empty() ? Visibility::Collapsed : Visibility::Visible);

_inputBuffer.clear();
// _editContext.NotifyFocusLeave();
_activeTextStart = 0;
_inComposition = false;

Expand Down
4 changes: 1 addition & 3 deletions src/cascadia/TerminalControl/TermControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3181,10 +3181,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_core.ColorSelection(fg, bg, matchMode);
}

// Returns the text cursor's position relative to our origin, in DIPs.
Microsoft::Terminal::Core::Point TermControl::CursorPositionInDips()
{
// const auto cursorPosition{ _core.CursorPosition() };

const til::point cursorPos{ _core.CursorPosition() };

const til::size fontSize{ til::math::flooring, CharacterDimensions() };
Expand All @@ -3198,7 +3197,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation

const til::point clientCursorInDips{ til::math::flooring, clientCursorPos.x / scaleFactor, clientCursorPos.y / scaleFactor };

// + SwapChainPanel().Margin().Top
auto padding{ GetPadding() };
til::point relativeToOrigin{ til::math::flooring,
clientCursorInDips.x + padding.Left,
Expand Down
38 changes: 16 additions & 22 deletions src/cascadia/TerminalSettingsModel/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,54 +664,48 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation

Model::SendInputArgs args{ winrt::hstring{ fmt::format(L"{}{}", backspaces, completionText.c_str()) } };
Model::ActionAndArgs actionAndArgs{ ShortcutAction::SendInput, args };
// Model::Command command{};

auto c = winrt::make_self<Command>();
c->_name = listText;
c->_ActionAndArgs = actionAndArgs;

// Try to assign a sensible icon
// Try to assign a sensible icon based on the result type. These are
// roughly chosen to align with the icons in
// https://github.com/PowerShell/PowerShellEditorServices/pull/1738
// as best as possible.
if (const auto resultType{ JsonUtils::GetValueForKey<int>(element, "ResultType") })
{
// PowerShell completion result -> Segoe Fluent icon value & name
switch (resultType)
{
case 1:
// History | |e81c History
case 1: // History -> 0xe81c History
c->_iconPath = L"\ue81c";
break;
case 2:
// Command | |ecaa AppIconDefault
case 2: // Command -> 0xecaa AppIconDefault
c->_iconPath = L"\uecaa";
break;
case 3:
// ProviderItem | |e8e4 AlignLeft
case 3: // ProviderItem -> 0xe8e4 AlignLeft
c->_iconPath = L"\ue8e4";
break;
case 4:
// ProviderContainer | |e838 FolderOpen
case 4: // ProviderContainer -> 0xe838 FolderOpen
c->_iconPath = L"\ue838";
break;
case 5:
// Property | |e7c1 Flag
case 5: // Property -> 0xe7c1 Flag
c->_iconPath = L"\ue7c1";
break;
case 6:
// Method | |ecaa AppIconDefault
case 6: // Method -> 0xecaa AppIconDefault
c->_iconPath = L"\uecaa";
break;
case 7:
// ParameterName | |e7c1 Flag
case 7: // ParameterName -> 0xe7c1 Flag
c->_iconPath = L"\ue7c1";
break;
case 8:
// ParameterValue | |f000 KnowledgeArticle
case 8: // ParameterValue -> 0xf000 KnowledgeArticle
c->_iconPath = L"\uf000";
break;
case 10:
// Namespace | |e943 Code
case 10: // Namespace -> 0xe943 Code
c->_iconPath = L"\ue943";
break;
case 13:
// DynamicKeyword | |e945 LightningBolt
case 13: // DynamicKeyword -> 0xe945 LightningBolt
c->_iconPath = L"\ue945";
break;
}
Expand Down

1 comment on commit 20f5651

@github-actions
Copy link

Choose a reason for hiding this comment

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

@check-spelling-bot Report

🔴 Please review

See the 📜action log for details.

Unrecognized words (1)

horizonally

Previously acknowledged words that are now absent CLA cpprest demoable everytime Hirots inthread pplx reingest unmark websockets :arrow_right:
To accept ✔️ these unrecognized words as correct and remove the previously acknowledged and now absent words, run the following commands

... in a clone of the git@github.com:microsoft/terminal.git repository
on the dev/migrie/fhl-2023/pwsh-autocomplete-demo branch (ℹ️ how do I use this?):

curl -s -S -L 'https://github.com/raw/check-spelling/check-spelling/v0.0.21/apply.pl' |
perl - 'https://github.com/microsoft/terminal/actions/runs/4306068390/attempts/1'
✏️ 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. If it doesn't work for you, you can manually add (one word per line) / remove items to expect.txt and the excludes.txt files.

If the listed items are:

  • ... misspelled, then please correct them instead of using the command.
  • ... names, please add them to .github/actions/spelling/allow/names.txt.
  • ... APIs, you can add them to a file in .github/actions/spelling/allow/.
  • ... just things you're using, please add them to an appropriate file in .github/actions/spelling/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/spelling/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. 😉

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Please sign in to comment.