Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit deeb281708acf66150f3ad519b50a475605670de
Author: Mike Griese <migrie@microsoft.com>
Date:   Fri Jun 7 06:11:21 2024 -0500

    format

commit deab3fe
Merge: eb750cc aeed078
Author: Mike Griese <migrie@microsoft.com>
Date:   Fri Jun 7 05:24:14 2024 -0500

    Merge remote-tracking branch 'origin/main' into dev/migrie/f/local-snippets-cleaner

commit eb750cc
Merge: f0bc7f1 ab65ecb
Author: Mike Griese <migrie@microsoft.com>
Date:   Fri Jun 7 05:21:24 2024 -0500

    Merge remote-tracking branch 'origin/dev/pabhoj/action_new_tab_menu' into dev/migrie/f/local-snippets-cleaner

commit ab65ecb
Merge: 0f7e9f3 cc837b6
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Jun 4 13:06:42 2024 -0700

    Merge branch 'dev/pabhoj/command_keys' into dev/pabhoj/action_new_tab_menu

commit cc837b6
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Jun 4 13:05:53 2024 -0700

    fix test

commit 0f7e9f3
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Jun 4 12:50:15 2024 -0700

    fixes

commit 589a1e0
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Jun 4 11:29:23 2024 -0700

    IDTo

commit 6ea25e4
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Jun 4 11:24:24 2024 -0700

    ID

commit 258c6eb
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Jun 4 11:19:49 2024 -0700

    O(1), rename maps for clarity

commit 327858b
Merge: 5a00d5f 96d8d1f
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Jun 4 10:20:27 2024 -0700

    Merge branch 'dev/pabhoj/action_refactor' into dev/pabhoj/command_keys

commit 96d8d1f
Merge: 406312f ece0c04
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Jun 4 10:19:47 2024 -0700

    Merge branch 'main' of https://github.com/microsoft/terminal into dev/pabhoj/action_refactor

commit 5a00d5f
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Mon Jun 3 16:13:37 2024 -0700

    nits and changes

commit 253dedf
Merge: d4d216c 406312f
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Mon Jun 3 11:31:47 2024 -0700

    conflict

commit f0bc7f1
Author: Mike Griese <migrie@microsoft.com>
Date:   Sat Jun 1 21:42:03 2024 -0500

    last cleanup before review

commit 3aa5b4b
Author: Mike Griese <migrie@microsoft.com>
Date:   Sat Jun 1 21:19:33 2024 -0500

    more cleanup

commit 091797c
Author: Mike Griese <migrie@microsoft.com>
Date:   Sat Jun 1 21:03:58 2024 -0500

    cleanup

commit d41e973
Author: Mike Griese <migrie@microsoft.com>
Date:   Sat Jun 1 20:44:47 2024 -0500

    a much cleaner abstraction

commit 5a029f0
Author: Mike Griese <migrie@microsoft.com>
Date:   Sat Jun 1 20:11:15 2024 -0500

    smaller refactors

commit bba8aac
Author: Mike Griese <migrie@microsoft.com>
Date:   Sat Jun 1 14:37:50 2024 -0500

    use a cache in actionmap to stash commands as we parse them

commit 5466965
Author: Mike Griese <migrie@microsoft.com>
Date:   Sat Jun 1 13:52:38 2024 -0500

    Actually works in suggestions UI again

commit b5d063b
Author: Mike Griese <migrie@microsoft.com>
Date:   Sat Jun 1 12:27:21 2024 -0500

    plumb it through. It works

      (cherry-picked from 3899919)

commit 406312f
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Fri May 31 19:33:07 2024 -0700

    fix loops

commit 625753c
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Fri May 31 17:52:20 2024 -0700

    x86 hash

commit a80316d
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Fri May 31 16:56:34 2024 -0700

    1 more test

commit 9703815
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Fri May 31 16:32:21 2024 -0700

    nits n fixes

commit 0dff336
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Fri May 31 10:51:36 2024 -0700

    nits, schema

commit b88a8c5
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Thu May 30 13:03:03 2024 -0700

    eraseif

commit 6c6dd46
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Mon May 20 15:06:31 2024 -0700

    leonard comments

commit 51528e9
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Thu May 16 16:59:35 2024 -0700

    spaces

commit 40b4aa2
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Thu May 16 16:50:56 2024 -0700

    works

commit d4d216c
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Wed May 8 10:48:33 2024 -0700

    don't need helper anymore

commit 7d00b25
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Wed May 8 10:11:16 2024 -0700

    spelling

commit ba375ec
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Wed May 8 10:00:45 2024 -0700

    remove keys from command

commit 5e48a45
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue May 7 15:56:52 2024 -0700

    update add action

commit 14d83b5
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Mon May 6 16:50:01 2024 -0700

    delete user actions that are identical to inbox actions

commit 3e31bda
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Mon May 6 15:29:24 2024 -0700

    generate here instead

commit 4d35c14
Merge: abef25d 3996806
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Fri May 3 14:54:09 2024 -0700

    schema conflict

commit abef25d
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Fri May 3 14:51:51 2024 -0700

    move this to header

commit 7793c5c
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Fri May 3 13:30:09 2024 -0700

    schema

commit ccf1cc9
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Thu May 2 19:06:51 2024 -0700

    nits

commit ebc03e9
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Thu May 2 18:44:44 2024 -0700

    another test

commit 80fc299
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Thu May 2 18:11:46 2024 -0700

    some new tests

commit 02a1e37
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Wed May 1 18:05:06 2024 -0700

    correct GH todo

commit 0480d65
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Wed May 1 17:54:46 2024 -0700

    this is better

commit 193e573
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Wed May 1 17:36:31 2024 -0700

    fix remaining tests

commit 2b16acd
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Wed May 1 14:48:37 2024 -0700

    check for name, fix some tests

commit f35bf20
Merge: cdb907d d380394
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Wed May 1 10:50:02 2024 -0700

    Merge branch 'main' of https://github.com/microsoft/terminal into dev/pabhoj/action_refactor

commit cdb907d
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Apr 30 17:43:25 2024 -0700

    mark todo

commit 3e601f5
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Apr 30 17:36:37 2024 -0700

    better if

commit c2c75c8
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Apr 30 17:33:53 2024 -0700

    bandaid temporary fix for name

commit 3c6015d
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Apr 30 16:45:59 2024 -0700

    remove _getcumulativeactions

commit 45cfcd6
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Apr 30 15:24:33 2024 -0700

    just add duplicate pane auto to defaults

commit ca4015f
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Apr 30 15:19:33 2024 -0700

    only one tojson

commit 4c744e6
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Apr 30 14:56:42 2024 -0700

    misc

commit 6437b9f
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Apr 30 14:36:09 2024 -0700

    fix user defaults file

commit 428821b
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Apr 30 13:04:14 2024 -0700

    remove _idwasgenerated

commit 3d92f27
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Apr 30 11:18:12 2024 -0700

    format

commit db00b90
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Apr 30 11:14:21 2024 -0700

    spelling things

commit e725f1e
Merge: e62dfa2 6bc7b9e
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Apr 30 11:09:51 2024 -0700

    resolve conflict

commit e62dfa2
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Apr 30 11:09:15 2024 -0700

    some comments

commit 2b4aeb2
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Apr 30 11:04:01 2024 -0700

    don't check for special in standard

commit 2f1d8d2
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Apr 30 10:34:58 2024 -0700

    update defaults

commit 754bf04
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Apr 30 10:27:25 2024 -0700

    mark gh todo

commit c51558f
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Apr 30 10:20:07 2024 -0700

    unmark these

commit 5a1b822
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Mon Apr 29 21:33:33 2024 -0700

    reimplement populating all known keybindings

commit b3e9c26
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Sat Apr 27 16:22:14 2024 -0700

    remove check for invalid

commit 936afd6
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Sat Apr 27 16:16:25 2024 -0700

    _getactionbyid no longer returns optional

commit dc874c3
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Sat Apr 27 15:36:17 2024 -0700

    rename to special/standard

commit ae16a5e
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Fri Apr 26 15:43:06 2024 -0700

    started stage 3

commit 3e7ab38
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Fri Apr 26 11:26:10 2024 -0700

    sui works?

commit ddfac90
Merge: f1633e0 41bb28c
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Fri Apr 26 09:56:46 2024 -0700

    Merge branch 'main' of https://github.com/microsoft/terminal into dev/pabhoj/action_refactor

commit f1633e0
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Thu Apr 25 21:25:17 2024 -0700

    overwritten IDs and overwritten keychords show up properly in the SUI

commit 12a61c5
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Thu Apr 25 19:16:27 2024 -0700

    shows up in sui and all keybindings work

commit d0938e2
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Wed Apr 24 18:15:37 2024 -0700

    ugly way to make sure we fixup

commit f425746
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Wed Apr 24 16:21:22 2024 -0700

    remove keysmap

commit e28d478
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Wed Apr 24 16:04:39 2024 -0700

    some todos for later

commit 0a3e17e
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Wed Apr 24 15:33:35 2024 -0700

    edge cases

commit 22ab936
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Wed Apr 24 14:33:01 2024 -0700

    works??

commit c134402
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Wed Apr 24 11:24:40 2024 -0700

    about to test stage 1

commit 85933e2
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Apr 23 09:49:27 2024 -0700

    midpoint

commit ca3eb87
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Wed Apr 17 16:58:04 2024 -0700

    rename and comment

commit 5e70911
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Wed Apr 17 16:49:58 2024 -0700

    remove 0

commit 360b92e
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Wed Apr 17 16:38:52 2024 -0700

    fmt_compile, fix test

commit 5ee630e
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Fri Apr 12 15:16:36 2024 -0700

    fmt is smart

commit aa49212
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Fri Apr 12 15:08:53 2024 -0700

    null check

commit 12f3aa9
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Fri Apr 12 15:04:23 2024 -0700

    truncate and hex, debug assert

commit bdf42c2
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Thu Apr 11 16:05:35 2024 -0700

    first round of nits

commit af2d22f
Merge: 6e293a5 5f3a857
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Thu Apr 11 09:42:42 2024 -0700

    defaults conflict

commit 6e293a5
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Mon Apr 1 10:26:54 2024 -0700

    Everytime

commit dd25ed7
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Mon Apr 1 10:23:23 2024 -0700

    change tests

commit dca7df5
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Fri Mar 29 13:49:33 2024 -0700

    excess line

commit 9fc6972
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Fri Mar 29 13:40:53 2024 -0700

    add tests

commit 5c2307c
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Thu Mar 28 11:48:51 2024 -0700

    fix test

commit d57c7a1
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Wed Mar 27 18:04:12 2024 -0700

    move this

commit 71bf90f
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Wed Mar 27 18:02:17 2024 -0700

    even better, also get the ID from json

commit 10d1fc8
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Wed Mar 27 17:30:55 2024 -0700

    this way is better

commit 44510dc
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Wed Mar 27 17:14:21 2024 -0700

    move id generation to fixupusersettings

commit eccd87f
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Wed Mar 27 15:38:50 2024 -0700

    update comment

commit 6c32539
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Wed Mar 27 15:37:19 2024 -0700

    string of numbers is unsightly but it works

commit 2093660
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Mar 26 11:45:44 2024 -0700

    line

commit b43191d
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Mar 26 11:44:47 2024 -0700

    spacing

commit 7c907fe
Merge: db528c9 e8f18ea
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Mar 26 11:43:50 2024 -0700

    nits

commit db528c9
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Mar 26 11:29:12 2024 -0700

    generate IDs for user commands

commit be193b2
Merge: 2bb1b6c 5f27280
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Mar 19 15:08:08 2024 -0700

    merge origin

commit 2bb1b6c
Merge: 66fe08f 5383cb3
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Mar 19 12:18:06 2024 -0700

    conflict

commit 66fe08f
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Wed Mar 6 17:24:39 2024 -0800

    default ids

commit 642d0ab
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Mar 5 15:47:49 2024 -0800

    inbox makes more sense

commit 8cc82de
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Mar 5 15:42:38 2024 -0800

    generated

commit 052d063
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Mar 5 14:36:45 2024 -0800

    ah one of the tests uses this

commit 8bcbd0b
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Mar 5 14:20:14 2024 -0800

    fix tests

commit 9dff28f
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Mar 5 13:51:18 2024 -0800

    update calls in tests

commit 90627b3
Author: Pankaj Bhojwani <pankaj.d.bhoj@gmail.com>
Date:   Tue Mar 5 11:35:26 2024 -0800

    add origin tag
  • Loading branch information
zadjii-msft committed Jun 7, 2024
1 parent aeed078 commit ae705f3
Show file tree
Hide file tree
Showing 15 changed files with 224 additions and 65 deletions.
28 changes: 28 additions & 0 deletions .wt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"actions":
[
{
"command": { "action": "sendInput", "input": "bx\r" },
"name": "Build project",
"description": "Build the project in the CWD"
},
{
"command": { "action": "sendInput", "input": "bz\r" },
"name": "Build solution, incremental",
"description": "Just build changes to the solution"
},
{
"command": { "action": "sendInput", "input": "bcz\r" },
"name": "Clean & build solution",
"icon": "\uE8e6",
"description": "Start over. Go get your coffee. "
},
{
"command": { "action": "sendInput", "input": "nuget push -apikey az -source TerminalDependencies %userprofile%\\Downloads" },

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

apikey is not a recognized word. (unrecognized-spelling)
"name": "Upload package to nuget feed",
"icon": "\uE898",
"description": "Go download a .nupkg, put it in ~/Downloads, and use this to push to our private feed."
},

]
}
111 changes: 61 additions & 50 deletions src/cascadia/TerminalApp/AppActionHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1330,64 +1330,75 @@ namespace winrt::TerminalApp::implementation
{
if (const auto& realArgs = args.ActionArgs().try_as<SuggestionsArgs>())
{
const auto source = realArgs.Source();
std::vector<Command> commandsCollection;
Control::CommandHistoryContext context{ nullptr };
winrt::hstring currentCommandline = L"";

// If the user wanted to use the current commandline to filter results,
// OR they wanted command history (or some other source that
// requires context from the control)
// then get that here.
const bool shouldGetContext = realArgs.UseCommandline() ||
WI_IsFlagSet(source, SuggestionsSource::CommandHistory);
if (shouldGetContext)
{
if (const auto& control{ _GetActiveControl() })
{
context = control.CommandHistory();
if (context)
{
currentCommandline = context.CurrentCommandline();
}
}
}
_doHandleSuggestions(realArgs);

args.Handled(true);
}
}
}

// Aggregate all the commands from the different sources that
// the user selected.
winrt::fire_and_forget TerminalPage::_doHandleSuggestions(SuggestionsArgs realArgs)
{
const auto source = realArgs.Source();
std::vector<Command> commandsCollection;
Control::CommandHistoryContext context{ nullptr };
winrt::hstring currentCommandline = L"";
winrt::hstring currentWorkingDirectory = L"";

// Tasks are all the sendInput commands the user has saved in
// their settings file. Ask the ActionMap for those.
if (WI_IsFlagSet(source, SuggestionsSource::Tasks))
{
const auto tasks = _settings.GlobalSettings().ActionMap().FilterToSendInput(currentCommandline);
for (const auto& t : tasks)
{
commandsCollection.push_back(t);
}
}
// If the user wanted to use the current commandline to filter results,
// OR they wanted command history (or some other source that
// requires context from the control)
// then get that here.
const bool shouldGetContext = realArgs.UseCommandline() ||
WI_IsAnyFlagSet(source, SuggestionsSource::CommandHistory);
if (const auto& control{ _GetActiveControl() })
{
currentWorkingDirectory = control.CurrentWorkingDirectory();

// Command History comes from the commands in the buffer,
// assuming the user has enabled shell integration. Get those
// from the active control.
if (WI_IsFlagSet(source, SuggestionsSource::CommandHistory) &&
context != nullptr)
if (shouldGetContext)
{
context = control.CommandHistory();
if (context)
{
const auto recentCommands = Command::HistoryToCommands(context.History(), currentCommandline, false);
for (const auto& t : recentCommands)
{
commandsCollection.push_back(t);
}
currentCommandline = context.CurrentCommandline();
}
}
}

// Open the palette with all these commands in it.
_OpenSuggestions(_GetActiveControl(),
winrt::single_threaded_vector<Command>(std::move(commandsCollection)),
SuggestionsMode::Palette,
currentCommandline);
args.Handled(true);
// Aggregate all the commands from the different sources that
// the user selected.

// Tasks are all the sendInput commands the user has saved in
// their settings file. Ask the ActionMap for those.
if (WI_IsFlagSet(source, SuggestionsSource::Tasks))
{
const auto tasks = co_await _settings.GlobalSettings().ActionMap().FilterToSnippets(currentCommandline, currentWorkingDirectory);
for (const auto& t : tasks)
{
commandsCollection.push_back(t);
}
}

// Command History comes from the commands in the buffer,
// assuming the user has enabled shell integration. Get those
// from the active control.
if (WI_IsFlagSet(source, SuggestionsSource::CommandHistory) &&
context != nullptr)
{
const auto recentCommands = Command::HistoryToCommands(context.History(), currentCommandline, false);
for (const auto& t : recentCommands)
{
commandsCollection.push_back(t);
}
}

co_await wil::resume_foreground(Dispatcher());

// Open the palette with all these commands in it.
_OpenSuggestions(_GetActiveControl(),
winrt::single_threaded_vector<Command>(std::move(commandsCollection)),
SuggestionsMode::Palette,
currentCommandline);
}

void TerminalPage::_HandleColorSelection(const IInspectable& /*sender*/,
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/TerminalPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ namespace winrt::TerminalApp::implementation
winrt::com_ptr<TerminalTab> _senderOrFocusedTab(const IInspectable& sender);

void _activePaneChanged(winrt::TerminalApp::TerminalTab tab, Windows::Foundation::IInspectable args);
winrt::fire_and_forget _doHandleSuggestions(Microsoft::Terminal::Settings::Model::SuggestionsArgs realArgs);

#pragma region ActionHandlers
// These are all defined in AppActionHandlers.cpp
Expand Down
5 changes: 5 additions & 0 deletions src/cascadia/TerminalControl/ControlCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2282,6 +2282,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
return *context;
}

winrt::hstring ControlCore::CurrentWorkingDirectory() const
{
return winrt::hstring{ _terminal->GetWorkingDirectory() };
}

Core::Scheme ControlCore::ColorScheme() const noexcept
{
Core::Scheme s;
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalControl/ControlCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation

void ContextMenuSelectCommand();
void ContextMenuSelectOutput();

winrt::hstring CurrentWorkingDirectory() const;
#pragma endregion

#pragma region ITerminalInput
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalControl/ICoreState.idl
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,7 @@ namespace Microsoft.Terminal.Control
void SelectOutput(Boolean goUp);
IVector<ScrollMark> ScrollMarks { get; };

String CurrentWorkingDirectory { get; };

};
}
4 changes: 4 additions & 0 deletions src/cascadia/TerminalControl/TermControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3558,6 +3558,10 @@ namespace winrt::Microsoft::Terminal::Control::implementation
{
return _core.CommandHistory();
}
winrt::hstring TermControl::CurrentWorkingDirectory() const
{
return _core.CurrentWorkingDirectory();
}

Core::Scheme TermControl::ColorScheme() const noexcept
{
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalControl/TermControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
void SelectCommand(const bool goUp);
void SelectOutput(const bool goUp);

winrt::hstring CurrentWorkingDirectory() const;
#pragma endregion

void ScrollViewport(int viewTop);
Expand Down
108 changes: 96 additions & 12 deletions src/cascadia/TerminalSettingsModel/ActionMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,10 +805,12 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
return _ExpandedCommandsCache;
}

IVector<Model::Command> _filterToSendInput(IMapView<hstring, Model::Command> nameMap,
winrt::hstring currentCommandline)
#pragma region Snippets
std::vector<Model::Command> _filterToSnippets(IMapView<hstring, Model::Command> nameMap,
winrt::hstring currentCommandline,
const std::vector<Model::Command>& localCommands)
{
auto results = winrt::single_threaded_vector<Model::Command>();
std::vector<Model::Command> results{};

const auto numBackspaces = currentCommandline.size();
// Helper to clone a sendInput command into a new Command, with the
Expand Down Expand Up @@ -847,21 +849,22 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
return *copy;
};

// iterate over all the commands in all our actions...
for (auto&& [name, command] : nameMap)
{
// Helper to copy this command into a snippet-styled command, and any
// nested commands
const auto addCommand = [&](auto& command) {
// If this is not a nested command, and it's a sendInput command...
if (!command.HasNestedCommands() &&
command.ActionAndArgs().Action() == ShortcutAction::SendInput)
{
// copy it into the results.
results.Append(createInputAction(command));
results.push_back(createInputAction(command));
}
// If this is nested...
else if (command.HasNestedCommands())
{
// Look for any sendInput commands nested underneath us
auto innerResults = _filterToSendInput(command.NestedCommands(), currentCommandline);
std::vector<Model::Command> empty{};
auto innerResults = winrt::single_threaded_vector<Model::Command>(std::move(_filterToSnippets(command.NestedCommands(), currentCommandline, empty)));

if (innerResults.Size() > 0)
{
Expand All @@ -874,17 +877,98 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
auto copy = cmdImpl->Copy();
copy->NestedCommands(innerResults.GetView());

results.Append(*copy);
results.push_back(*copy);
}
}
};

// iterate over all the commands in all our actions...
for (auto&& [name, command] : nameMap)
{
addCommand(command);
}
// ... and all the local commands passed in here
for (const auto& command : localCommands)
{
addCommand(command);
}

return results;
}

IVector<Model::Command> ActionMap::FilterToSendInput(
winrt::hstring currentCommandline)
// Update ActionMap's cache of actions for this directory. We'll look for a
// .wt.json in this directory. If it exists, we'll read it, parse it's JSON,
// then take all the sendInput actions in it and store them in our
// _cwdLocalSnippetsCache
winrt::Windows::Foundation::IAsyncAction ActionMap::_updateLocalSnippetCache(winrt::hstring currentWorkingDirectory)
{
return _filterToSendInput(NameMap(), currentCommandline);
// Don't do I/O on the main thread, duh

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

duh is not a recognized word. (unrecognized-spelling)
co_await winrt::resume_background();

// This returns an empty string if we fail to load the file.
auto localTasksFileContents = CascadiaSettings::ReadFile(currentWorkingDirectory + L"\\.wt.json");
if (!localTasksFileContents.empty())
{
auto data = winrt::to_string(localTasksFileContents);
std::string errs;
static std::unique_ptr<Json::CharReader> reader{ Json::CharReaderBuilder::CharReaderBuilder().newCharReader() };
Json::Value root;
if (!reader->parse(data.data(), data.data() + data.size(), &root, &errs))
{
// In the real settings parser, we'd throw here:
// throw winrt::hresult_error(WEB_E_INVALID_JSON_STRING, winrt::to_hstring(errs));
//
// That seems overly agressive for something that we don't

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

agressive is not a recognized word. (unrecognized-spelling)
// really own. Instead, just bail out.
co_return;
}

auto result = std::vector<Model::Command>();
if (auto actions{ root[JsonKey("actions")] })
{
std::vector<SettingsLoadWarnings> warnings;
for (const auto& json : actions)
{
auto parsed = Command::FromJson(json, warnings, OriginTag::Generated);
// Skip over things that aren't snippets
if (parsed->ActionAndArgs().Action() != ShortcutAction::SendInput)
{
continue;
}

result.push_back(*parsed);
}
}

_cwdLocalSnippetsCache.insert_or_assign(currentWorkingDirectory, result);
}

// Now at the bottom, we've either found a file successfully parsed it,
// and updated the _cwdLocalSnippetsCache. Or we failed at some point,
// and then it doesn't really matter.
co_return;
}

winrt::Windows::Foundation::IAsyncOperation<IVector<Model::Command>> ActionMap::FilterToSnippets(
winrt::hstring currentCommandline,
winrt::hstring currentWorkingDirectory)
{
// Check if there are any cached commands in this directory.
// If there aren't, then we'll try to look for any commands in this
// dir's .wt.json
auto cachedCwdCommands = _cwdLocalSnippetsCache.find(currentWorkingDirectory);
if (cachedCwdCommands == _cwdLocalSnippetsCache.end())
{
// Here, we haven't cached this path yet
co_await _updateLocalSnippetCache(currentWorkingDirectory);
cachedCwdCommands = _cwdLocalSnippetsCache.find(currentWorkingDirectory);
}

auto cachedCommands = cachedCwdCommands != _cwdLocalSnippetsCache.end() ?
cachedCwdCommands->second :
std::vector<Model::Command>{};

co_return winrt::single_threaded_vector<Model::Command>(_filterToSnippets(NameMap(), currentCommandline, cachedCommands));
}
#pragma endregion
}
6 changes: 5 additions & 1 deletion src/cascadia/TerminalSettingsModel/ActionMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
void ExpandCommands(const Windows::Foundation::Collections::IVectorView<Model::Profile>& profiles,
const Windows::Foundation::Collections::IMapView<winrt::hstring, Model::ColorScheme>& schemes);

winrt::Windows::Foundation::Collections::IVector<Model::Command> FilterToSendInput(winrt::hstring currentCommandline);
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::Foundation::Collections::IVector<Model::Command>> FilterToSnippets(winrt::hstring currentCommandline, winrt::hstring currentWorkingDirectory);

private:
Model::Command _GetActionByID(const winrt::hstring& actionID) const;
Expand All @@ -101,6 +101,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
void _TryUpdateActionMap(const Model::Command& cmd);
void _TryUpdateKeyChord(const Model::Command& cmd, const Control::KeyChord& keys);

winrt::Windows::Foundation::IAsyncAction _updateLocalSnippetCache(winrt::hstring currentWorkingDirectory);

Windows::Foundation::Collections::IMap<hstring, Model::ActionAndArgs> _AvailableActionsCache{ nullptr };
Windows::Foundation::Collections::IMap<hstring, Model::Command> _NameMapCache{ nullptr };
Windows::Foundation::Collections::IMap<Control::KeyChord, Model::Command> _GlobalHotkeysCache{ nullptr };
Expand Down Expand Up @@ -133,6 +135,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
// we can give the SUI a view of the key chords and the commands they map to
Windows::Foundation::Collections::IMap<Control::KeyChord, Model::Command> _ResolvedKeyToActionMapCache{ nullptr };

std::unordered_map<hstring, std::vector<Model::Command>> _cwdLocalSnippetsCache{};

friend class SettingsModelUnitTests::KeyBindingsTests;
friend class SettingsModelUnitTests::DeserializationTests;
friend class SettingsModelUnitTests::TerminalSettingsTests;
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalSettingsModel/ActionMap.idl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Microsoft.Terminal.Settings.Model

IVector<Command> ExpandedCommands { get; };

IVector<Command> FilterToSendInput(String CurrentCommandline);
Windows.Foundation.IAsyncOperation<IVector<Command> > FilterToSnippets(String CurrentCommandline, String CurrentWorkingDirectory);
};

[default_interface] runtimeclass ActionMap : IActionMapView
Expand Down
Loading

1 comment on commit ae705f3

@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 or 📝 job summary for details.

Unrecognized words (3)

agressive
apikey
duh

Previously acknowledged words that are now absent CRLFs Redir wcsicmp 🫥
To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands

... in a clone of the git@github.com:microsoft/terminal.git repository
on the dev/migrie/f/local-snippets-final-FINAL branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.22/apply.pl' |
perl - 'https://github.com/microsoft/terminal/actions/runs/9416097909/attempts/1'
Available 📚 dictionaries could cover words (expected and unrecognized) not in the 📘 dictionary

This includes both expected items (2213) from .github/actions/spelling/expect/04cdb9b77d6827c0202f51acd4205b017015bfff.txt
.github/actions/spelling/expect/alphabet.txt
.github/actions/spelling/expect/expect.txt
.github/actions/spelling/expect/web.txt and unrecognized words (3)

Dictionary Entries Covers Uniquely
cspell:cpp/src/lang-jargon.txt 11 1 1
cspell:swift/src/swift.txt 53 1 1
cspell:gaming-terms/dict/gaming-terms.txt 59 1 1
cspell:monkeyc/src/monkeyc_keywords.txt 123 1 1
cspell:cryptocurrencies/cryptocurrencies.txt 125 1 1

Consider adding them (in .github/workflows/spelling2.yml) for uses: check-spelling/check-spelling@v0.0.22 in its with:

      with:
        extra_dictionaries:
          cspell:cpp/src/lang-jargon.txt
          cspell:swift/src/swift.txt
          cspell:gaming-terms/dict/gaming-terms.txt
          cspell:monkeyc/src/monkeyc_keywords.txt
          cspell:cryptocurrencies/cryptocurrencies.txt

To stop checking additional dictionaries, add (in .github/workflows/spelling2.yml) for uses: check-spelling/check-spelling@v0.0.22 in its with:

check_extra_dictionaries: ''
Errors (1)

See the 📜action log or 📝 job summary for details.

❌ Errors Count
❌ ignored-expect-variant 3

See ❌ Event descriptions for more information.

✏️ 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.

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.