From ae705f3ae1ef7bfe55293f5e01c62e94eb762da0 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Fri, 7 Jun 2024 06:13:24 -0500 Subject: [PATCH 01/11] Squashed commit of the following: commit deeb281708acf66150f3ad519b50a475605670de Author: Mike Griese Date: Fri Jun 7 06:11:21 2024 -0500 format commit deab3fe05bfd833c7794c8ea44a09a9a89baf01c Merge: eb750cca2 aeed0782b Author: Mike Griese Date: Fri Jun 7 05:24:14 2024 -0500 Merge remote-tracking branch 'origin/main' into dev/migrie/f/local-snippets-cleaner commit eb750cca265929c87799b34cc517049e5b7d6858 Merge: f0bc7f1a2 ab65ecbb3 Author: Mike Griese 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 ab65ecbb3930c91f935512e0c2f9df469d14fc6d Merge: 0f7e9f331 cc837b6e5 Author: Pankaj Bhojwani Date: Tue Jun 4 13:06:42 2024 -0700 Merge branch 'dev/pabhoj/command_keys' into dev/pabhoj/action_new_tab_menu commit cc837b6e5d8eb08468c2c47155c28cd9bada7216 Author: Pankaj Bhojwani Date: Tue Jun 4 13:05:53 2024 -0700 fix test commit 0f7e9f331ba52437e0b9fafbdf1533ba3cb22b9d Author: Pankaj Bhojwani Date: Tue Jun 4 12:50:15 2024 -0700 fixes commit 589a1e0f968e864577f5121c529beb0a208acd4d Author: Pankaj Bhojwani Date: Tue Jun 4 11:29:23 2024 -0700 IDTo commit 6ea25e4381cb2bf7521877fb4c169d0c910a28af Author: Pankaj Bhojwani Date: Tue Jun 4 11:24:24 2024 -0700 ID commit 258c6eb1f8acb8dff18d9d584384845835a498e2 Author: Pankaj Bhojwani Date: Tue Jun 4 11:19:49 2024 -0700 O(1), rename maps for clarity commit 327858b2af76da34f8117aa7bb77bc11eab95ce2 Merge: 5a00d5f40 96d8d1f8e Author: Pankaj Bhojwani Date: Tue Jun 4 10:20:27 2024 -0700 Merge branch 'dev/pabhoj/action_refactor' into dev/pabhoj/command_keys commit 96d8d1f8eaae1f56778dd9b39c83931241eca4a7 Merge: 406312f2f ece0c04c3 Author: Pankaj Bhojwani Date: Tue Jun 4 10:19:47 2024 -0700 Merge branch 'main' of https://github.com/microsoft/terminal into dev/pabhoj/action_refactor commit 5a00d5f4001c41143375ce997a5293ea2634ae9e Author: Pankaj Bhojwani Date: Mon Jun 3 16:13:37 2024 -0700 nits and changes commit 253dedf4773bb6182ef30188e71841785aafe1f9 Merge: d4d216ca3 406312f2f Author: Pankaj Bhojwani Date: Mon Jun 3 11:31:47 2024 -0700 conflict commit f0bc7f1a282aa2138fa7e47704bc155706dcf020 Author: Mike Griese Date: Sat Jun 1 21:42:03 2024 -0500 last cleanup before review commit 3aa5b4bb295effff318d7dd99fb210d5dac54260 Author: Mike Griese Date: Sat Jun 1 21:19:33 2024 -0500 more cleanup commit 091797c08b6ab9be74b6563dbf562c693bd0629d Author: Mike Griese Date: Sat Jun 1 21:03:58 2024 -0500 cleanup commit d41e9735aff27ab0339cc9a2b7ab399d1c69f1d1 Author: Mike Griese Date: Sat Jun 1 20:44:47 2024 -0500 a much cleaner abstraction commit 5a029f07442a41319cf2ccbe1a6a7383ab1e8012 Author: Mike Griese Date: Sat Jun 1 20:11:15 2024 -0500 smaller refactors commit bba8aac96d669f0bd06bf18156339c6522b2125e Author: Mike Griese Date: Sat Jun 1 14:37:50 2024 -0500 use a cache in actionmap to stash commands as we parse them commit 5466965d4f7720d4cf30133d70252631271b7bcf Author: Mike Griese Date: Sat Jun 1 13:52:38 2024 -0500 Actually works in suggestions UI again commit b5d063b48eb3fe2a77f6b8da15195909c89ed683 Author: Mike Griese Date: Sat Jun 1 12:27:21 2024 -0500 plumb it through. It works (cherry-picked from 38999195b) commit 406312f2f821ea130f1e1e475adde25b9de83c33 Author: Pankaj Bhojwani Date: Fri May 31 19:33:07 2024 -0700 fix loops commit 625753cc41e7f9995b04ee4e0e1f97e9ed55160f Author: Pankaj Bhojwani Date: Fri May 31 17:52:20 2024 -0700 x86 hash commit a80316dfa50007a177d0e45687ea51fee07b857c Author: Pankaj Bhojwani Date: Fri May 31 16:56:34 2024 -0700 1 more test commit 9703815f59731f96b82c5ffd154b59b45ce116d4 Author: Pankaj Bhojwani Date: Fri May 31 16:32:21 2024 -0700 nits n fixes commit 0dff33655649d4f060fc4450783bc818777e7f68 Author: Pankaj Bhojwani Date: Fri May 31 10:51:36 2024 -0700 nits, schema commit b88a8c58843637771798d2c53e224d0ca7ec1a3d Author: Pankaj Bhojwani Date: Thu May 30 13:03:03 2024 -0700 eraseif commit 6c6dd46e0265de1af21188d9ddcdc5679910fbbe Author: Pankaj Bhojwani Date: Mon May 20 15:06:31 2024 -0700 leonard comments commit 51528e9cfd87289c2a896d8c460086036029d833 Author: Pankaj Bhojwani Date: Thu May 16 16:59:35 2024 -0700 spaces commit 40b4aa2c945e3a2779261eadac4b9d158471f84c Author: Pankaj Bhojwani Date: Thu May 16 16:50:56 2024 -0700 works commit d4d216ca3395a26529ecadb0c73472c108baadcf Author: Pankaj Bhojwani Date: Wed May 8 10:48:33 2024 -0700 don't need helper anymore commit 7d00b25fbf6f52b0207eb8df27b9358cef256a87 Author: Pankaj Bhojwani Date: Wed May 8 10:11:16 2024 -0700 spelling commit ba375ec2a250e9ded990a590e5c9c7a028a45bb3 Author: Pankaj Bhojwani Date: Wed May 8 10:00:45 2024 -0700 remove keys from command commit 5e48a45ba2abd6bf1dfc6cfb11e826a5f89d4785 Author: Pankaj Bhojwani Date: Tue May 7 15:56:52 2024 -0700 update add action commit 14d83b5f5c1c9e2ac2ad89c5384c408098876f02 Author: Pankaj Bhojwani Date: Mon May 6 16:50:01 2024 -0700 delete user actions that are identical to inbox actions commit 3e31bda6f2c3b427979552f74070466cc9374523 Author: Pankaj Bhojwani Date: Mon May 6 15:29:24 2024 -0700 generate here instead commit 4d35c14966f1e818dabebfdf854a7310e8d7c2bc Merge: abef25d29 399680650 Author: Pankaj Bhojwani Date: Fri May 3 14:54:09 2024 -0700 schema conflict commit abef25d29c59a5be291b52411db6b403e98fba73 Author: Pankaj Bhojwani Date: Fri May 3 14:51:51 2024 -0700 move this to header commit 7793c5c5bc06aa3a024d7a2b5611922d6f7f7472 Author: Pankaj Bhojwani Date: Fri May 3 13:30:09 2024 -0700 schema commit ccf1cc9e834728d425fb7fcd808ce0da33e6d900 Author: Pankaj Bhojwani Date: Thu May 2 19:06:51 2024 -0700 nits commit ebc03e98f454acd6399849ff08e5b99d9431e538 Author: Pankaj Bhojwani Date: Thu May 2 18:44:44 2024 -0700 another test commit 80fc299c1011156d74276ca3c193068b2d0b1d95 Author: Pankaj Bhojwani Date: Thu May 2 18:11:46 2024 -0700 some new tests commit 02a1e37aaea7c37c184495fdd81a85894dfadb1e Author: Pankaj Bhojwani Date: Wed May 1 18:05:06 2024 -0700 correct GH todo commit 0480d651cb43c91a74fbaa8e5ff5e4bdfa020519 Author: Pankaj Bhojwani Date: Wed May 1 17:54:46 2024 -0700 this is better commit 193e5733bf1493929f85469ffe5919b8d32fcb53 Author: Pankaj Bhojwani Date: Wed May 1 17:36:31 2024 -0700 fix remaining tests commit 2b16acd4cfe5f00cb12a90d9d38aef0cc803b276 Author: Pankaj Bhojwani Date: Wed May 1 14:48:37 2024 -0700 check for name, fix some tests commit f35bf206e66de6aa28fa2750c424769c1bc649e8 Merge: cdb907d94 d3803943c Author: Pankaj Bhojwani Date: Wed May 1 10:50:02 2024 -0700 Merge branch 'main' of https://github.com/microsoft/terminal into dev/pabhoj/action_refactor commit cdb907d94d26784bb3fc3d0a302cd8799b889b8b Author: Pankaj Bhojwani Date: Tue Apr 30 17:43:25 2024 -0700 mark todo commit 3e601f5b6683b6e775b14cc9d51a7a90377ae575 Author: Pankaj Bhojwani Date: Tue Apr 30 17:36:37 2024 -0700 better if commit c2c75c80ed15e4adfede1d0bb910e12d9b53b2fa Author: Pankaj Bhojwani Date: Tue Apr 30 17:33:53 2024 -0700 bandaid temporary fix for name commit 3c6015d97bf5f354ff1814f260fabc478cb0a96a Author: Pankaj Bhojwani Date: Tue Apr 30 16:45:59 2024 -0700 remove _getcumulativeactions commit 45cfcd6ecaf410bd085683697436adb8351115ad Author: Pankaj Bhojwani Date: Tue Apr 30 15:24:33 2024 -0700 just add duplicate pane auto to defaults commit ca4015f5f98f223a7606afad68613814d04e75b4 Author: Pankaj Bhojwani Date: Tue Apr 30 15:19:33 2024 -0700 only one tojson commit 4c744e6ab358031168afa7338533f8001ca71b75 Author: Pankaj Bhojwani Date: Tue Apr 30 14:56:42 2024 -0700 misc commit 6437b9f5082fcb74d16b4ba2a336d64a8dc5a4c7 Author: Pankaj Bhojwani Date: Tue Apr 30 14:36:09 2024 -0700 fix user defaults file commit 428821b40c028a868dccda6a762cc4244245f83e Author: Pankaj Bhojwani Date: Tue Apr 30 13:04:14 2024 -0700 remove _idwasgenerated commit 3d92f27de766b91e12d9d7166a5d95d6308a5d5d Author: Pankaj Bhojwani Date: Tue Apr 30 11:18:12 2024 -0700 format commit db00b90306948de50c51d57b2418924b4b2d5a74 Author: Pankaj Bhojwani Date: Tue Apr 30 11:14:21 2024 -0700 spelling things commit e725f1e936b2188d47e1f2a112cfe41048c3583d Merge: e62dfa217 6bc7b9e68 Author: Pankaj Bhojwani Date: Tue Apr 30 11:09:51 2024 -0700 resolve conflict commit e62dfa21770dae6c2286bd2bd3e831b104cbad7c Author: Pankaj Bhojwani Date: Tue Apr 30 11:09:15 2024 -0700 some comments commit 2b4aeb2b11c83b07aa312250b803598e85b3e938 Author: Pankaj Bhojwani Date: Tue Apr 30 11:04:01 2024 -0700 don't check for special in standard commit 2f1d8d2dca71af0cc50a2d48f3a352717a971412 Author: Pankaj Bhojwani Date: Tue Apr 30 10:34:58 2024 -0700 update defaults commit 754bf04ab34531d1a2004bc603c16e2cff4ace90 Author: Pankaj Bhojwani Date: Tue Apr 30 10:27:25 2024 -0700 mark gh todo commit c51558ff4ce20fefb0742dd36ddaeadf9cda39c4 Author: Pankaj Bhojwani Date: Tue Apr 30 10:20:07 2024 -0700 unmark these commit 5a1b8228332aff2fde6f394385d85d1f4379fa10 Author: Pankaj Bhojwani Date: Mon Apr 29 21:33:33 2024 -0700 reimplement populating all known keybindings commit b3e9c267f5ed66b4dc49506c3ac4b3c3a676433a Author: Pankaj Bhojwani Date: Sat Apr 27 16:22:14 2024 -0700 remove check for invalid commit 936afd6b0190a55497e6410e009e45dab721cccd Author: Pankaj Bhojwani Date: Sat Apr 27 16:16:25 2024 -0700 _getactionbyid no longer returns optional commit dc874c3b3f03bbbe014e4eae2171107390f12177 Author: Pankaj Bhojwani Date: Sat Apr 27 15:36:17 2024 -0700 rename to special/standard commit ae16a5e0e1989e4baec6c463db5279e93bd8a705 Author: Pankaj Bhojwani Date: Fri Apr 26 15:43:06 2024 -0700 started stage 3 commit 3e7ab3861a29bc3e063ccabd25c37e2fea41f256 Author: Pankaj Bhojwani Date: Fri Apr 26 11:26:10 2024 -0700 sui works? commit ddfac907f401ef36b42acf268b139979578904a3 Merge: f1633e036 41bb28c46 Author: Pankaj Bhojwani Date: Fri Apr 26 09:56:46 2024 -0700 Merge branch 'main' of https://github.com/microsoft/terminal into dev/pabhoj/action_refactor commit f1633e0360105c8d1426803301a67e3d2b73d141 Author: Pankaj Bhojwani Date: Thu Apr 25 21:25:17 2024 -0700 overwritten IDs and overwritten keychords show up properly in the SUI commit 12a61c595e97f549f67b425ad90851514fac1b13 Author: Pankaj Bhojwani Date: Thu Apr 25 19:16:27 2024 -0700 shows up in sui and all keybindings work commit d0938e2a246833ee1d0fd5c31e3a62b10c391ea8 Author: Pankaj Bhojwani Date: Wed Apr 24 18:15:37 2024 -0700 ugly way to make sure we fixup commit f425746169c7c9069e424a13b72ef9c1e64e88bb Author: Pankaj Bhojwani Date: Wed Apr 24 16:21:22 2024 -0700 remove keysmap commit e28d47888c992f05fa9b467946c6a8374d3538be Author: Pankaj Bhojwani Date: Wed Apr 24 16:04:39 2024 -0700 some todos for later commit 0a3e17eebb3453268f7723c3bd57c6e0404d23ff Author: Pankaj Bhojwani Date: Wed Apr 24 15:33:35 2024 -0700 edge cases commit 22ab9363efda5c6f6be0564cddf1042fc85a6631 Author: Pankaj Bhojwani Date: Wed Apr 24 14:33:01 2024 -0700 works?? commit c134402507540288e7c5fe878cc21c8eb555a1b1 Author: Pankaj Bhojwani Date: Wed Apr 24 11:24:40 2024 -0700 about to test stage 1 commit 85933e2231c0ecf465894efa88d886cee73d93a9 Author: Pankaj Bhojwani Date: Tue Apr 23 09:49:27 2024 -0700 midpoint commit ca3eb87301044355f0afb995f4d0822a847b19cd Author: Pankaj Bhojwani Date: Wed Apr 17 16:58:04 2024 -0700 rename and comment commit 5e70911a68b2c5482cbe0682c615d61a680c9274 Author: Pankaj Bhojwani Date: Wed Apr 17 16:49:58 2024 -0700 remove 0 commit 360b92e56764033d1f4e943abde803bc056066f1 Author: Pankaj Bhojwani Date: Wed Apr 17 16:38:52 2024 -0700 fmt_compile, fix test commit 5ee630ec82b795328d696b042e8d2f5f1127544f Author: Pankaj Bhojwani Date: Fri Apr 12 15:16:36 2024 -0700 fmt is smart commit aa4921268e1531b49b24c141dd3620d99db6b8cb Author: Pankaj Bhojwani Date: Fri Apr 12 15:08:53 2024 -0700 null check commit 12f3aa9d06eb1b98da2a4412f90da6e4a84f9dbb Author: Pankaj Bhojwani Date: Fri Apr 12 15:04:23 2024 -0700 truncate and hex, debug assert commit bdf42c2d9c2ca4a925087603c3dd2fe1be127373 Author: Pankaj Bhojwani Date: Thu Apr 11 16:05:35 2024 -0700 first round of nits commit af2d22f34368464602bd9ac42104af7ba40b0c02 Merge: 6e293a5ee 5f3a85719 Author: Pankaj Bhojwani Date: Thu Apr 11 09:42:42 2024 -0700 defaults conflict commit 6e293a5ee8504747286c9c54adc396a66afb84e9 Author: Pankaj Bhojwani Date: Mon Apr 1 10:26:54 2024 -0700 Everytime commit dd25ed762f3663f930842b1b101ed3d3422f2f12 Author: Pankaj Bhojwani Date: Mon Apr 1 10:23:23 2024 -0700 change tests commit dca7df50c88c37d08d020607d315db5ca93a7958 Author: Pankaj Bhojwani Date: Fri Mar 29 13:49:33 2024 -0700 excess line commit 9fc69721c9c6f10cd9d8fc396341d424ff71589c Author: Pankaj Bhojwani Date: Fri Mar 29 13:40:53 2024 -0700 add tests commit 5c2307c531e3ec5e6452a1dfc897ef55c2f63eda Author: Pankaj Bhojwani Date: Thu Mar 28 11:48:51 2024 -0700 fix test commit d57c7a1f0352d829a55875e50a4c92976c616d0d Author: Pankaj Bhojwani Date: Wed Mar 27 18:04:12 2024 -0700 move this commit 71bf90f2952062915544362a4a206e77f6401982 Author: Pankaj Bhojwani Date: Wed Mar 27 18:02:17 2024 -0700 even better, also get the ID from json commit 10d1fc8d60c7d97cad1e5178c068ada24bc82a3e Author: Pankaj Bhojwani Date: Wed Mar 27 17:30:55 2024 -0700 this way is better commit 44510dce1b6ae6ec21ce16d39ffa2c79a7b3c0a5 Author: Pankaj Bhojwani Date: Wed Mar 27 17:14:21 2024 -0700 move id generation to fixupusersettings commit eccd87f30354c702c14799b3fc3d828324450c99 Author: Pankaj Bhojwani Date: Wed Mar 27 15:38:50 2024 -0700 update comment commit 6c3253968f8ee9ac46f0256e4d2c14c06731bb51 Author: Pankaj Bhojwani Date: Wed Mar 27 15:37:19 2024 -0700 string of numbers is unsightly but it works commit 2093660ac126e0babb749dfa1809a65541900268 Author: Pankaj Bhojwani Date: Tue Mar 26 11:45:44 2024 -0700 line commit b43191d2c52773c63d9d24eeab09b6dc7bc57213 Author: Pankaj Bhojwani Date: Tue Mar 26 11:44:47 2024 -0700 spacing commit 7c907fed6e03fe07facd2caa6c56a9e1ac84ffdc Merge: db528c94f e8f18ea92 Author: Pankaj Bhojwani Date: Tue Mar 26 11:43:50 2024 -0700 nits commit db528c94fc1eee3668b5bb37966618cfc4a097b7 Author: Pankaj Bhojwani Date: Tue Mar 26 11:29:12 2024 -0700 generate IDs for user commands commit be193b21ebae89f5925f575d98aab9088c7c6fe8 Merge: 2bb1b6c6a 5f272804c Author: Pankaj Bhojwani Date: Tue Mar 19 15:08:08 2024 -0700 merge origin commit 2bb1b6c6adf5a025f36796d1476a9461657b4914 Merge: 66fe08f96 5383cb3a1 Author: Pankaj Bhojwani Date: Tue Mar 19 12:18:06 2024 -0700 conflict commit 66fe08f964e11b283344914e75a34c1d6df76d91 Author: Pankaj Bhojwani Date: Wed Mar 6 17:24:39 2024 -0800 default ids commit 642d0ab2b7ae79cae049f6efce91785937f33a60 Author: Pankaj Bhojwani Date: Tue Mar 5 15:47:49 2024 -0800 inbox makes more sense commit 8cc82de489f550748247632113576c438fdd94b8 Author: Pankaj Bhojwani Date: Tue Mar 5 15:42:38 2024 -0800 generated commit 052d06368671ce1feaaf2e61dd1d7e3826dbe680 Author: Pankaj Bhojwani Date: Tue Mar 5 14:36:45 2024 -0800 ah one of the tests uses this commit 8bcbd0bd423e7c4c45d03a1b21ba34fa3452a3b5 Author: Pankaj Bhojwani Date: Tue Mar 5 14:20:14 2024 -0800 fix tests commit 9dff28f23d069230b5383fc8473d101c64dd17a9 Author: Pankaj Bhojwani Date: Tue Mar 5 13:51:18 2024 -0800 update calls in tests commit 90627b3ae5c4f0e3be694351adeb795c5e9eef8e Author: Pankaj Bhojwani Date: Tue Mar 5 11:35:26 2024 -0800 add origin tag --- .wt.json | 28 +++++ .../TerminalApp/AppActionHandlers.cpp | 111 ++++++++++-------- src/cascadia/TerminalApp/TerminalPage.h | 1 + src/cascadia/TerminalControl/ControlCore.cpp | 5 + src/cascadia/TerminalControl/ControlCore.h | 2 + src/cascadia/TerminalControl/ICoreState.idl | 2 + src/cascadia/TerminalControl/TermControl.cpp | 4 + src/cascadia/TerminalControl/TermControl.h | 1 + .../TerminalSettingsModel/ActionMap.cpp | 108 +++++++++++++++-- .../TerminalSettingsModel/ActionMap.h | 6 +- .../TerminalSettingsModel/ActionMap.idl | 2 +- .../CascadiaSettings.cpp | 14 +++ .../TerminalSettingsModel/CascadiaSettings.h | 1 + .../CascadiaSettings.idl | 1 + .../TerminalSettingsSerializationHelpers.h | 3 +- 15 files changed, 224 insertions(+), 65 deletions(-) create mode 100644 .wt.json diff --git a/.wt.json b/.wt.json new file mode 100644 index 00000000000..83caf18a27a --- /dev/null +++ b/.wt.json @@ -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" }, + "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." + }, + + ] +} diff --git a/src/cascadia/TerminalApp/AppActionHandlers.cpp b/src/cascadia/TerminalApp/AppActionHandlers.cpp index d044cbe13f2..4a0ac5f603e 100644 --- a/src/cascadia/TerminalApp/AppActionHandlers.cpp +++ b/src/cascadia/TerminalApp/AppActionHandlers.cpp @@ -1330,64 +1330,75 @@ namespace winrt::TerminalApp::implementation { if (const auto& realArgs = args.ActionArgs().try_as()) { - const auto source = realArgs.Source(); - std::vector 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 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(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(std::move(commandsCollection)), + SuggestionsMode::Palette, + currentCommandline); } void TerminalPage::_HandleColorSelection(const IInspectable& /*sender*/, diff --git a/src/cascadia/TerminalApp/TerminalPage.h b/src/cascadia/TerminalApp/TerminalPage.h index 7095dbaf290..a7795ec58fd 100644 --- a/src/cascadia/TerminalApp/TerminalPage.h +++ b/src/cascadia/TerminalApp/TerminalPage.h @@ -544,6 +544,7 @@ namespace winrt::TerminalApp::implementation winrt::com_ptr _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 diff --git a/src/cascadia/TerminalControl/ControlCore.cpp b/src/cascadia/TerminalControl/ControlCore.cpp index 6b4b86a194d..db86bfee5dc 100644 --- a/src/cascadia/TerminalControl/ControlCore.cpp +++ b/src/cascadia/TerminalControl/ControlCore.cpp @@ -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; diff --git a/src/cascadia/TerminalControl/ControlCore.h b/src/cascadia/TerminalControl/ControlCore.h index 0798cc6c1fe..701503d5870 100644 --- a/src/cascadia/TerminalControl/ControlCore.h +++ b/src/cascadia/TerminalControl/ControlCore.h @@ -184,6 +184,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation void ContextMenuSelectCommand(); void ContextMenuSelectOutput(); + + winrt::hstring CurrentWorkingDirectory() const; #pragma endregion #pragma region ITerminalInput diff --git a/src/cascadia/TerminalControl/ICoreState.idl b/src/cascadia/TerminalControl/ICoreState.idl index a3333473c28..7bd5411c6fe 100644 --- a/src/cascadia/TerminalControl/ICoreState.idl +++ b/src/cascadia/TerminalControl/ICoreState.idl @@ -62,5 +62,7 @@ namespace Microsoft.Terminal.Control void SelectOutput(Boolean goUp); IVector ScrollMarks { get; }; + String CurrentWorkingDirectory { get; }; + }; } diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index cc97cf6aa57..5eebd3dab5c 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -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 { diff --git a/src/cascadia/TerminalControl/TermControl.h b/src/cascadia/TerminalControl/TermControl.h index 75d49c3b317..3fde55c3ee0 100644 --- a/src/cascadia/TerminalControl/TermControl.h +++ b/src/cascadia/TerminalControl/TermControl.h @@ -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); diff --git a/src/cascadia/TerminalSettingsModel/ActionMap.cpp b/src/cascadia/TerminalSettingsModel/ActionMap.cpp index 4468014c5a8..16591dae5a7 100644 --- a/src/cascadia/TerminalSettingsModel/ActionMap.cpp +++ b/src/cascadia/TerminalSettingsModel/ActionMap.cpp @@ -805,10 +805,12 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation return _ExpandedCommandsCache; } - IVector _filterToSendInput(IMapView nameMap, - winrt::hstring currentCommandline) +#pragma region Snippets + std::vector _filterToSnippets(IMapView nameMap, + winrt::hstring currentCommandline, + const std::vector& localCommands) { - auto results = winrt::single_threaded_vector(); + std::vector results{}; const auto numBackspaces = currentCommandline.size(); // Helper to clone a sendInput command into a new Command, with the @@ -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 empty{}; + auto innerResults = winrt::single_threaded_vector(std::move(_filterToSnippets(command.NestedCommands(), currentCommandline, empty))); if (innerResults.Size() > 0) { @@ -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 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 + 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 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 + // really own. Instead, just bail out. + co_return; + } + + auto result = std::vector(); + if (auto actions{ root[JsonKey("actions")] }) + { + std::vector 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> 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{}; + + co_return winrt::single_threaded_vector(_filterToSnippets(NameMap(), currentCommandline, cachedCommands)); } +#pragma endregion } diff --git a/src/cascadia/TerminalSettingsModel/ActionMap.h b/src/cascadia/TerminalSettingsModel/ActionMap.h index 2b815214dcb..c219fceddb0 100644 --- a/src/cascadia/TerminalSettingsModel/ActionMap.h +++ b/src/cascadia/TerminalSettingsModel/ActionMap.h @@ -83,7 +83,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation void ExpandCommands(const Windows::Foundation::Collections::IVectorView& profiles, const Windows::Foundation::Collections::IMapView& schemes); - winrt::Windows::Foundation::Collections::IVector FilterToSendInput(winrt::hstring currentCommandline); + winrt::Windows::Foundation::IAsyncOperation> FilterToSnippets(winrt::hstring currentCommandline, winrt::hstring currentWorkingDirectory); private: Model::Command _GetActionByID(const winrt::hstring& actionID) const; @@ -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 _AvailableActionsCache{ nullptr }; Windows::Foundation::Collections::IMap _NameMapCache{ nullptr }; Windows::Foundation::Collections::IMap _GlobalHotkeysCache{ nullptr }; @@ -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 _ResolvedKeyToActionMapCache{ nullptr }; + std::unordered_map> _cwdLocalSnippetsCache{}; + friend class SettingsModelUnitTests::KeyBindingsTests; friend class SettingsModelUnitTests::DeserializationTests; friend class SettingsModelUnitTests::TerminalSettingsTests; diff --git a/src/cascadia/TerminalSettingsModel/ActionMap.idl b/src/cascadia/TerminalSettingsModel/ActionMap.idl index 594872f6b70..79e91477b98 100644 --- a/src/cascadia/TerminalSettingsModel/ActionMap.idl +++ b/src/cascadia/TerminalSettingsModel/ActionMap.idl @@ -22,7 +22,7 @@ namespace Microsoft.Terminal.Settings.Model IVector ExpandedCommands { get; }; - IVector FilterToSendInput(String CurrentCommandline); + Windows.Foundation.IAsyncOperation > FilterToSnippets(String CurrentCommandline, String CurrentWorkingDirectory); }; [default_interface] runtimeclass ActionMap : IActionMapView diff --git a/src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp b/src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp index e22905d3652..839c5a474eb 100644 --- a/src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp +++ b/src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp @@ -1095,6 +1095,20 @@ void CascadiaSettings::ExportFile(winrt::hstring path, winrt::hstring content) } CATCH_LOG(); } +winrt::hstring CascadiaSettings::ReadFile(winrt::hstring path) +{ + try + { + auto maybeContents = ReadUTF8FileIfExists({ path.c_str() }); + if (maybeContents.has_value()) + { + return winrt::hstring{ til::u8u16(*maybeContents) }; + } + } + CATCH_LOG(); + + return L""; +} void CascadiaSettings::_validateThemeExists() { diff --git a/src/cascadia/TerminalSettingsModel/CascadiaSettings.h b/src/cascadia/TerminalSettingsModel/CascadiaSettings.h index 03553c8b73d..a650a7f75f5 100644 --- a/src/cascadia/TerminalSettingsModel/CascadiaSettings.h +++ b/src/cascadia/TerminalSettingsModel/CascadiaSettings.h @@ -113,6 +113,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation static winrt::hstring ApplicationVersion(); static bool IsPortableMode(); static void ExportFile(winrt::hstring path, winrt::hstring content); + static winrt::hstring ReadFile(winrt::hstring path); CascadiaSettings() noexcept = default; CascadiaSettings(const winrt::hstring& userJSON, const winrt::hstring& inboxJSON); diff --git a/src/cascadia/TerminalSettingsModel/CascadiaSettings.idl b/src/cascadia/TerminalSettingsModel/CascadiaSettings.idl index 165a7fed9fa..e10229d3640 100644 --- a/src/cascadia/TerminalSettingsModel/CascadiaSettings.idl +++ b/src/cascadia/TerminalSettingsModel/CascadiaSettings.idl @@ -21,6 +21,7 @@ namespace Microsoft.Terminal.Settings.Model static String ApplicationVersion { get; }; static void ExportFile(String path, String content); + static String ReadFile(String path); CascadiaSettings(String userJSON, String inboxJSON); diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h b/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h index da06d0cfba3..1a7a85846aa 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h +++ b/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h @@ -501,9 +501,10 @@ JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::FindMatchDirecti JSON_FLAG_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::SuggestionsSource) { - static constexpr std::array mappings = { + static constexpr std::array mappings = { pair_type{ "none", AllClear }, pair_type{ "tasks", ValueType::Tasks }, + pair_type{ "snippets", ValueType::Tasks }, pair_type{ "commandHistory", ValueType::CommandHistory }, pair_type{ "directoryHistory", ValueType::DirectoryHistory }, pair_type{ "all", AllSet }, From 73bb68ca3672447ab74a4ad1d29265671f643627 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Mon, 10 Jun 2024 16:18:32 -0500 Subject: [PATCH 02/11] spel --- .wt.json | 2 +- src/cascadia/TerminalSettingsModel/ActionMap.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.wt.json b/.wt.json index 83caf18a27a..1f53e30bad0 100644 --- a/.wt.json +++ b/.wt.json @@ -18,7 +18,7 @@ "description": "Start over. Go get your coffee. " }, { - "command": { "action": "sendInput", "input": "nuget push -apikey az -source TerminalDependencies %userprofile%\\Downloads" }, + "command": { "action": "sendInput", "input": "nuget push -ApiKey az -source TerminalDependencies %userprofile%\\Downloads" }, "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." diff --git a/src/cascadia/TerminalSettingsModel/ActionMap.cpp b/src/cascadia/TerminalSettingsModel/ActionMap.cpp index 16591dae5a7..f6e8d494949 100644 --- a/src/cascadia/TerminalSettingsModel/ActionMap.cpp +++ b/src/cascadia/TerminalSettingsModel/ActionMap.cpp @@ -902,7 +902,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation // _cwdLocalSnippetsCache winrt::Windows::Foundation::IAsyncAction ActionMap::_updateLocalSnippetCache(winrt::hstring currentWorkingDirectory) { - // Don't do I/O on the main thread, duh + // Don't do I/O on the main thread co_await winrt::resume_background(); // This returns an empty string if we fail to load the file. @@ -918,7 +918,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation // 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 + // That seems overly aggressive for something that we don't // really own. Instead, just bail out. co_return; } From 81b77bf4899e244f558c06cca794fcbb0415754a Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Tue, 2 Jul 2024 14:12:26 -0500 Subject: [PATCH 03/11] this does work --- .wt.json | 14 ++-- .../TerminalSettingsModel/ActionMap.cpp | 5 +- .../TerminalSettingsModel/Command.cpp | 68 +++++++++++++++++++ src/cascadia/TerminalSettingsModel/Command.h | 2 + 4 files changed, 79 insertions(+), 10 deletions(-) diff --git a/.wt.json b/.wt.json index 1f53e30bad0..44f718f42e2 100644 --- a/.wt.json +++ b/.wt.json @@ -1,28 +1,28 @@ { - "actions": + "$version": "1.0.0", + "snippets": [ { - "command": { "action": "sendInput", "input": "bx\r" }, + "input": "bx\r", "name": "Build project", "description": "Build the project in the CWD" }, { - "command": { "action": "sendInput", "input": "bz\r" }, + "input": "bz\r", "name": "Build solution, incremental", "description": "Just build changes to the solution" }, { - "command": { "action": "sendInput", "input": "bcz\r" }, + "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" }, + "input": "nuget push -ApiKey az -source TerminalDependencies %userprofile%\\Downloads", "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." - }, - + } ] } diff --git a/src/cascadia/TerminalSettingsModel/ActionMap.cpp b/src/cascadia/TerminalSettingsModel/ActionMap.cpp index 99e45e6f73e..eeb202f9f85 100644 --- a/src/cascadia/TerminalSettingsModel/ActionMap.cpp +++ b/src/cascadia/TerminalSettingsModel/ActionMap.cpp @@ -940,12 +940,11 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation } auto result = std::vector(); - if (auto actions{ root[JsonKey("actions")] }) + if (auto actions{ root[JsonKey("snippets")] }) { - std::vector warnings; for (const auto& json : actions) { - auto parsed = Command::FromJson(json, warnings, OriginTag::Generated); + auto parsed = Command::FromSnippetJson(json); // Skip over things that aren't snippets if (parsed->ActionAndArgs().Action() != ShortcutAction::SendInput) { diff --git a/src/cascadia/TerminalSettingsModel/Command.cpp b/src/cascadia/TerminalSettingsModel/Command.cpp index 21ea3431993..075ff4b4f60 100644 --- a/src/cascadia/TerminalSettingsModel/Command.cpp +++ b/src/cascadia/TerminalSettingsModel/Command.cpp @@ -286,6 +286,74 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation return result; } + winrt::com_ptr Command::FromSnippetJson(const Json::Value& json) + { + auto result = winrt::make_self(); + result->_Origin = OriginTag::Generated; + + //auto nested = false; + JsonUtils::GetValueForKey(json, IDKey, result->_ID); + // JsonUtils::GetValueForKey(json, IterateOnKey, result->_IterateOn); + JsonUtils::GetValueForKey(json, DescriptionKey, result->_Description); + JsonUtils::GetValueForKey(json, IconKey, result->_iconPath); + result->_name = _nameFromJson(json); + + // // For iterable commands, we'll make another pass at parsing them once + // // the json is patched. So ignore parsing sub-commands for now. Commands + // // will only be marked iterable on the first pass. + // if (const auto nestedCommandsJson{ json[JsonKey(CommandsKey)] }) + // { + // // Initialize our list of subcommands. + // result->_subcommands = winrt::single_threaded_map(); + // result->_nestedCommand = true; + // Command::LayerSnippetJson(result->_subcommands, nestedCommandsJson, OriginTag::Generated); + + // if (result->_subcommands.Size() == 0) + // { + // result->_ActionAndArgs = make(); + // } + + // nested = true; + // } + // else if (json.isMember(JsonKey(CommandsKey))) + // { + // // { "name": "foo", "commands": null } will land in this case, which + // // should also be used for unbinding. + + // // create an "invalid" ActionAndArgs + // result->_ActionAndArgs = make(); + // result->_nestedCommand = true; + // } + // else if (!nested) + // { + auto action{ ShortcutAction::SendInput }; + IActionArgs args{ nullptr }; + std::vector parseWarnings; + std::tie(args, parseWarnings) = SendInputArgs::FromJson(json); + // auto args{ *SendInputArgs::FromJson(json) }; + result->_ActionAndArgs = *winrt::make_self(action, args); + // } + + // // If we're a nested command, we can ignore the current action. + // if (!nested) + // { + // if (const auto actionJson{ json[JsonKey(ActionKey)] }) + // { + // result->_ActionAndArgs = *ActionAndArgs::FromJson(actionJson, warnings); + // } + // else + // { + // // { name: "foo", action: null } will land in this case, which + // // should also be used for unbinding. + + // // create an "invalid" ActionAndArgs + // result->_ActionAndArgs = make(); + // } + // } + + return result; + } + // Function Description: // - Attempt to parse all the json objects in `json` into new Command // objects, and add them to the map of commands. diff --git a/src/cascadia/TerminalSettingsModel/Command.h b/src/cascadia/TerminalSettingsModel/Command.h index 194ed7dc95e..1bc92220ca3 100644 --- a/src/cascadia/TerminalSettingsModel/Command.h +++ b/src/cascadia/TerminalSettingsModel/Command.h @@ -51,6 +51,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation std::vector& warnings, const OriginTag origin); + static winrt::com_ptr FromSnippetJson(const Json::Value& json); + static void ExpandCommands(Windows::Foundation::Collections::IMap& commands, Windows::Foundation::Collections::IVectorView profiles, Windows::Foundation::Collections::IVectorView schemes); From c7b6b6f44a731fb098c84afd81d919b284e0890b Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Tue, 2 Jul 2024 14:17:48 -0500 Subject: [PATCH 04/11] cleanup --- .../TerminalSettingsModel/ActionMap.cpp | 4 +- .../TerminalSettingsModel/Command.cpp | 58 +++---------------- 2 files changed, 11 insertions(+), 51 deletions(-) diff --git a/src/cascadia/TerminalSettingsModel/ActionMap.cpp b/src/cascadia/TerminalSettingsModel/ActionMap.cpp index eeb202f9f85..6e890bf0813 100644 --- a/src/cascadia/TerminalSettingsModel/ActionMap.cpp +++ b/src/cascadia/TerminalSettingsModel/ActionMap.cpp @@ -926,9 +926,9 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation if (!localTasksFileContents.empty()) { auto data = winrt::to_string(localTasksFileContents); - std::string errs; - static std::unique_ptr reader{ Json::CharReaderBuilder::CharReaderBuilder().newCharReader() }; Json::Value root; + std::string errs; + const std::unique_ptr reader{ Json::CharReaderBuilder{}.newCharReader() }; if (!reader->parse(data.data(), data.data() + data.size(), &root, &errs)) { // In the real settings parser, we'd throw here: diff --git a/src/cascadia/TerminalSettingsModel/Command.cpp b/src/cascadia/TerminalSettingsModel/Command.cpp index 075ff4b4f60..79de2ba2798 100644 --- a/src/cascadia/TerminalSettingsModel/Command.cpp +++ b/src/cascadia/TerminalSettingsModel/Command.cpp @@ -286,70 +286,30 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation return result; } + // This is substantially simpler than the normal FromJson. We just want to take something that looks like: + // { + // "input": "bx", + // "name": "Build project", + // "description": "Build the project in the CWD" + // }, + // + // and turn it into a sendInput action. No need to figure out what kind of + // action parser, or deal with nesting, or iterable commands or anything. winrt::com_ptr Command::FromSnippetJson(const Json::Value& json) { auto result = winrt::make_self(); result->_Origin = OriginTag::Generated; - //auto nested = false; JsonUtils::GetValueForKey(json, IDKey, result->_ID); - // JsonUtils::GetValueForKey(json, IterateOnKey, result->_IterateOn); JsonUtils::GetValueForKey(json, DescriptionKey, result->_Description); JsonUtils::GetValueForKey(json, IconKey, result->_iconPath); result->_name = _nameFromJson(json); - // // For iterable commands, we'll make another pass at parsing them once - // // the json is patched. So ignore parsing sub-commands for now. Commands - // // will only be marked iterable on the first pass. - // if (const auto nestedCommandsJson{ json[JsonKey(CommandsKey)] }) - // { - // // Initialize our list of subcommands. - // result->_subcommands = winrt::single_threaded_map(); - // result->_nestedCommand = true; - // Command::LayerSnippetJson(result->_subcommands, nestedCommandsJson, OriginTag::Generated); - - // if (result->_subcommands.Size() == 0) - // { - // result->_ActionAndArgs = make(); - // } - - // nested = true; - // } - // else if (json.isMember(JsonKey(CommandsKey))) - // { - // // { "name": "foo", "commands": null } will land in this case, which - // // should also be used for unbinding. - - // // create an "invalid" ActionAndArgs - // result->_ActionAndArgs = make(); - // result->_nestedCommand = true; - // } - // else if (!nested) - // { auto action{ ShortcutAction::SendInput }; IActionArgs args{ nullptr }; std::vector parseWarnings; std::tie(args, parseWarnings) = SendInputArgs::FromJson(json); - // auto args{ *SendInputArgs::FromJson(json) }; result->_ActionAndArgs = *winrt::make_self(action, args); - // } - - // // If we're a nested command, we can ignore the current action. - // if (!nested) - // { - // if (const auto actionJson{ json[JsonKey(ActionKey)] }) - // { - // result->_ActionAndArgs = *ActionAndArgs::FromJson(actionJson, warnings); - // } - // else - // { - // // { name: "foo", action: null } will land in this case, which - // // should also be used for unbinding. - - // // create an "invalid" ActionAndArgs - // result->_ActionAndArgs = make(); - // } - // } return result; } From 6dfbe5bafafb88b07cff95c341a5269fdbaee6ba Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Tue, 16 Jul 2024 15:56:12 -0500 Subject: [PATCH 05/11] ew --- .../TerminalApp/AppActionHandlers.cpp | 1 + .../TerminalApp/SnippetsPaneContent.cpp | 6 ++- .../TerminalApp/SnippetsPaneContent.h | 2 +- .../TerminalSettingsModel/ActionMap.cpp | 39 ++++++++++++------- .../TerminalSettingsModel/ActionMap.h | 2 +- .../TerminalSettingsModel/Command.cpp | 2 +- 6 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/cascadia/TerminalApp/AppActionHandlers.cpp b/src/cascadia/TerminalApp/AppActionHandlers.cpp index 98e9ecb732c..8a9436235b1 100644 --- a/src/cascadia/TerminalApp/AppActionHandlers.cpp +++ b/src/cascadia/TerminalApp/AppActionHandlers.cpp @@ -1480,6 +1480,7 @@ namespace winrt::TerminalApp::implementation if (WI_IsFlagSet(source, SuggestionsSource::Tasks)) { const auto tasks = co_await _settings.GlobalSettings().ActionMap().FilterToSnippets(currentCommandline, currentWorkingDirectory); + // ----- we may be on a background thread here ----- for (const auto& t : tasks) { commandsCollection.push_back(t); diff --git a/src/cascadia/TerminalApp/SnippetsPaneContent.cpp b/src/cascadia/TerminalApp/SnippetsPaneContent.cpp index b772cddac43..b6415c6ba79 100644 --- a/src/cascadia/TerminalApp/SnippetsPaneContent.cpp +++ b/src/cascadia/TerminalApp/SnippetsPaneContent.cpp @@ -42,7 +42,7 @@ namespace winrt::TerminalApp::implementation } } - void SnippetsPaneContent::UpdateSettings(const CascadiaSettings& settings) + winrt::fire_and_forget SnippetsPaneContent::UpdateSettings(const CascadiaSettings& settings) { _settings = settings; @@ -51,7 +51,9 @@ namespace winrt::TerminalApp::implementation // has typed, then relies on the suggestions UI to _also_ filter with that // string. - const auto tasks = _settings.GlobalSettings().ActionMap().FilterToSendInput(winrt::hstring{}); // IVector + const auto tasks = co_await _settings.GlobalSettings().ActionMap().FilterToSnippets(winrt::hstring{}, winrt::hstring{}); // IVector + co_await wil::resume_foreground(Dispatcher()); + _allTasks = winrt::single_threaded_observable_vector(); for (const auto& t : tasks) { diff --git a/src/cascadia/TerminalApp/SnippetsPaneContent.h b/src/cascadia/TerminalApp/SnippetsPaneContent.h index 205ab3c8e76..19f85559824 100644 --- a/src/cascadia/TerminalApp/SnippetsPaneContent.h +++ b/src/cascadia/TerminalApp/SnippetsPaneContent.h @@ -17,7 +17,7 @@ namespace winrt::TerminalApp::implementation winrt::Windows::UI::Xaml::FrameworkElement GetRoot(); - void UpdateSettings(const winrt::Microsoft::Terminal::Settings::Model::CascadiaSettings& settings); + winrt::fire_and_forget UpdateSettings(const winrt::Microsoft::Terminal::Settings::Model::CascadiaSettings& settings); winrt::Windows::Foundation::Size MinimumSize(); void Focus(winrt::Windows::UI::Xaml::FocusState reason = winrt::Windows::UI::Xaml::FocusState::Programmatic); diff --git a/src/cascadia/TerminalSettingsModel/ActionMap.cpp b/src/cascadia/TerminalSettingsModel/ActionMap.cpp index 4f0a02aa596..0e645e5b206 100644 --- a/src/cascadia/TerminalSettingsModel/ActionMap.cpp +++ b/src/cascadia/TerminalSettingsModel/ActionMap.cpp @@ -885,7 +885,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation }; // iterate over all the commands in all our actions... - for (auto&& [name, command] : nameMap) + for (auto&& [_, command] : nameMap) { addCommand(command); } @@ -924,7 +924,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation 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"); + const auto localTasksFileContents = CascadiaSettings::ReadFile(currentWorkingDirectory + L"\\.wt.json"); if (!localTasksFileContents.empty()) { auto data = winrt::to_string(localTasksFileContents); @@ -946,7 +946,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation { for (const auto& json : actions) { - auto parsed = Command::FromSnippetJson(json); + const auto parsed = Command::FromSnippetJson(json); // Skip over things that aren't snippets if (parsed->ActionAndArgs().Action() != ShortcutAction::SendInput) { @@ -956,8 +956,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation result.push_back(*parsed); } } - - _cwdLocalSnippetsCache.insert_or_assign(currentWorkingDirectory, result); + auto cache{ _cwdLocalSnippetsCache.lock() }; + cache->insert_or_assign(currentWorkingDirectory, result); } // Now at the bottom, we've either found a file successfully parsed it, @@ -970,22 +970,31 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation 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()) + bool hitCache = false; { - // Here, we haven't cached this path yet - co_await _updateLocalSnippetCache(currentWorkingDirectory); - cachedCwdCommands = _cwdLocalSnippetsCache.find(currentWorkingDirectory); + auto cache{ _cwdLocalSnippetsCache.lock_shared() }; + + // 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 = cache->find(currentWorkingDirectory); + hitCache = cachedCwdCommands != cache->end(); + if (hitCache) + { + co_return winrt::single_threaded_vector(_filterToSnippets(NameMap(), currentCommandline, cachedCwdCommands->second)); + } } + // Here, we haven't cached this path yet + co_await _updateLocalSnippetCache(currentWorkingDirectory); - auto cachedCommands = cachedCwdCommands != _cwdLocalSnippetsCache.end() ? + auto cache{ _cwdLocalSnippetsCache.lock_shared() }; + auto cachedCwdCommands = cache->find(currentWorkingDirectory); + auto cachedCommands = cachedCwdCommands != cache->end() ? cachedCwdCommands->second : std::vector{}; - co_return winrt::single_threaded_vector(_filterToSnippets(NameMap(), currentCommandline, cachedCommands)); + + // } } #pragma endregion } diff --git a/src/cascadia/TerminalSettingsModel/ActionMap.h b/src/cascadia/TerminalSettingsModel/ActionMap.h index 882746f1b12..bdcd554fe93 100644 --- a/src/cascadia/TerminalSettingsModel/ActionMap.h +++ b/src/cascadia/TerminalSettingsModel/ActionMap.h @@ -136,7 +136,7 @@ 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 _ResolvedKeyToActionMapCache{ nullptr }; - std::unordered_map> _cwdLocalSnippetsCache{}; + til::shared_mutex>> _cwdLocalSnippetsCache{}; friend class SettingsModelUnitTests::KeyBindingsTests; friend class SettingsModelUnitTests::DeserializationTests; diff --git a/src/cascadia/TerminalSettingsModel/Command.cpp b/src/cascadia/TerminalSettingsModel/Command.cpp index 79de2ba2798..56b0205d344 100644 --- a/src/cascadia/TerminalSettingsModel/Command.cpp +++ b/src/cascadia/TerminalSettingsModel/Command.cpp @@ -305,7 +305,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation JsonUtils::GetValueForKey(json, IconKey, result->_iconPath); result->_name = _nameFromJson(json); - auto action{ ShortcutAction::SendInput }; + const auto action{ ShortcutAction::SendInput }; IActionArgs args{ nullptr }; std::vector parseWarnings; std::tie(args, parseWarnings) = SendInputArgs::FromJson(json); From a5fcc833b496eb23ad862451f1839e7dafda94f3 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Tue, 16 Jul 2024 16:12:46 -0500 Subject: [PATCH 06/11] better --- .../TerminalSettingsModel/ActionMap.cpp | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/cascadia/TerminalSettingsModel/ActionMap.cpp b/src/cascadia/TerminalSettingsModel/ActionMap.cpp index 0e645e5b206..2da1a875889 100644 --- a/src/cascadia/TerminalSettingsModel/ActionMap.cpp +++ b/src/cascadia/TerminalSettingsModel/ActionMap.cpp @@ -970,6 +970,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation winrt::hstring currentCommandline, winrt::hstring currentWorkingDirectory) { + using iter = std::unordered_map>::const_iterator; + iter cachedCwdCommands; bool hitCache = false; { auto cache{ _cwdLocalSnippetsCache.lock_shared() }; @@ -977,21 +979,27 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation // 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 = cache->find(currentWorkingDirectory); + cachedCwdCommands = cache->find(currentWorkingDirectory); hitCache = cachedCwdCommands != cache->end(); - if (hitCache) - { - co_return winrt::single_threaded_vector(_filterToSnippets(NameMap(), currentCommandline, cachedCwdCommands->second)); - } + // if (hitCache) + // { + // co_return winrt::single_threaded_vector(_filterToSnippets(NameMap(), currentCommandline, cachedCwdCommands->second)); + // } } - // Here, we haven't cached this path yet - co_await _updateLocalSnippetCache(currentWorkingDirectory); + if (!hitCache) + { + // Here, we haven't cached this path yet + co_await _updateLocalSnippetCache(currentWorkingDirectory); - auto cache{ _cwdLocalSnippetsCache.lock_shared() }; - auto cachedCwdCommands = cache->find(currentWorkingDirectory); - auto cachedCommands = cachedCwdCommands != cache->end() ? - cachedCwdCommands->second : - std::vector{}; + auto cache{ _cwdLocalSnippetsCache.lock_shared() }; + cachedCwdCommands = cache->find(currentWorkingDirectory); + hitCache = cachedCwdCommands != cache->end(); + } + // { + // } + auto cachedCommands = hitCache ? + cachedCwdCommands->second : + std::vector{}; co_return winrt::single_threaded_vector(_filterToSnippets(NameMap(), currentCommandline, cachedCommands)); // } From b2f276b8a31258a5a442bba12ef7641aac70bdd1 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Tue, 16 Jul 2024 16:18:17 -0500 Subject: [PATCH 07/11] more better... --- .../TerminalSettingsModel/ActionMap.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/cascadia/TerminalSettingsModel/ActionMap.cpp b/src/cascadia/TerminalSettingsModel/ActionMap.cpp index 2da1a875889..e2acf17dc20 100644 --- a/src/cascadia/TerminalSettingsModel/ActionMap.cpp +++ b/src/cascadia/TerminalSettingsModel/ActionMap.cpp @@ -981,28 +981,25 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation // dir's .wt.json cachedCwdCommands = cache->find(currentWorkingDirectory); hitCache = cachedCwdCommands != cache->end(); - // if (hitCache) - // { - // co_return winrt::single_threaded_vector(_filterToSnippets(NameMap(), currentCommandline, cachedCwdCommands->second)); - // } - } + } // release the lock on the cache + if (!hitCache) { // Here, we haven't cached this path yet co_await _updateLocalSnippetCache(currentWorkingDirectory); + // now re-lock auto cache{ _cwdLocalSnippetsCache.lock_shared() }; cachedCwdCommands = cache->find(currentWorkingDirectory); hitCache = cachedCwdCommands != cache->end(); } - // { - // } auto cachedCommands = hitCache ? - cachedCwdCommands->second : - std::vector{}; - co_return winrt::single_threaded_vector(_filterToSnippets(NameMap(), currentCommandline, cachedCommands)); + cachedCwdCommands->second : + std::vector{}; - // } + co_return winrt::single_threaded_vector(_filterToSnippets(NameMap(), + currentCommandline, + cachedCommands)); } #pragma endregion } From 6f3609fa955c082fe04905d222a9ab639594a3ae Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Tue, 16 Jul 2024 17:00:15 -0500 Subject: [PATCH 08/11] best locking --- .../TerminalSettingsModel/ActionMap.cpp | 52 ++++++++----------- .../TerminalSettingsModel/ActionMap.h | 2 +- 2 files changed, 24 insertions(+), 30 deletions(-) diff --git a/src/cascadia/TerminalSettingsModel/ActionMap.cpp b/src/cascadia/TerminalSettingsModel/ActionMap.cpp index e2acf17dc20..924d0895c2c 100644 --- a/src/cascadia/TerminalSettingsModel/ActionMap.cpp +++ b/src/cascadia/TerminalSettingsModel/ActionMap.cpp @@ -918,11 +918,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation // .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) + std::vector ActionMap::_updateLocalSnippetCache(winrt::hstring currentWorkingDirectory) { - // Don't do I/O on the main thread - co_await winrt::resume_background(); - // This returns an empty string if we fail to load the file. const auto localTasksFileContents = CascadiaSettings::ReadFile(currentWorkingDirectory + L"\\.wt.json"); if (!localTasksFileContents.empty()) @@ -938,7 +935,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation // // That seems overly aggressive for something that we don't // really own. Instead, just bail out. - co_return; + return {}; } auto result = std::vector(); @@ -956,50 +953,47 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation result.push_back(*parsed); } } - auto cache{ _cwdLocalSnippetsCache.lock() }; - cache->insert_or_assign(currentWorkingDirectory, result); + return 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; + return {}; } winrt::Windows::Foundation::IAsyncOperation> ActionMap::FilterToSnippets( winrt::hstring currentCommandline, winrt::hstring currentWorkingDirectory) { - using iter = std::unordered_map>::const_iterator; - iter cachedCwdCommands; - bool hitCache = false; { - auto cache{ _cwdLocalSnippetsCache.lock_shared() }; - // 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 - cachedCwdCommands = cache->find(currentWorkingDirectory); - hitCache = cachedCwdCommands != cache->end(); + const auto& cache{ _cwdLocalSnippetsCache.lock_shared() }; + + const auto cacheIterator = cache->find(currentWorkingDirectory); + if (cacheIterator != cache->end()) + { + // We found something in the cache! return it. + co_return winrt::single_threaded_vector(_filterToSnippets(NameMap(), + currentCommandline, + cacheIterator->second)); + } } // release the lock on the cache - if (!hitCache) - { - // Here, we haven't cached this path yet - co_await _updateLocalSnippetCache(currentWorkingDirectory); + // Don't do I/O on the main thread + co_await winrt::resume_background(); - // now re-lock - auto cache{ _cwdLocalSnippetsCache.lock_shared() }; - cachedCwdCommands = cache->find(currentWorkingDirectory); - hitCache = cachedCwdCommands != cache->end(); + auto result = _updateLocalSnippetCache(currentWorkingDirectory); + if (!result.empty()) + { + // We found something! Add it to the cache + auto cache{ _cwdLocalSnippetsCache.lock() }; + cache->insert_or_assign(currentWorkingDirectory, result); } - auto cachedCommands = hitCache ? - cachedCwdCommands->second : - std::vector{}; co_return winrt::single_threaded_vector(_filterToSnippets(NameMap(), currentCommandline, - cachedCommands)); + result)); } #pragma endregion } diff --git a/src/cascadia/TerminalSettingsModel/ActionMap.h b/src/cascadia/TerminalSettingsModel/ActionMap.h index bdcd554fe93..e3ceb3f5188 100644 --- a/src/cascadia/TerminalSettingsModel/ActionMap.h +++ b/src/cascadia/TerminalSettingsModel/ActionMap.h @@ -102,7 +102,7 @@ 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); + std::vector _updateLocalSnippetCache(winrt::hstring currentWorkingDirectory); Windows::Foundation::Collections::IMap _AvailableActionsCache{ nullptr }; Windows::Foundation::Collections::IMap _NameMapCache{ nullptr }; From 0605b61169ab062bc22c04871702890b7080facb Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Tue, 23 Jul 2024 09:55:14 -0500 Subject: [PATCH 09/11] coulda swore we needed to stdmove into winrt arrays --- src/cascadia/TerminalSettingsModel/ActionMap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cascadia/TerminalSettingsModel/ActionMap.cpp b/src/cascadia/TerminalSettingsModel/ActionMap.cpp index 1943f31a4b2..f3794f35950 100644 --- a/src/cascadia/TerminalSettingsModel/ActionMap.cpp +++ b/src/cascadia/TerminalSettingsModel/ActionMap.cpp @@ -867,7 +867,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation { // Look for any sendInput commands nested underneath us std::vector empty{}; - auto innerResults = winrt::single_threaded_vector(std::move(_filterToSnippets(command.NestedCommands(), currentCommandline, empty))); + auto innerResults = winrt::single_threaded_vector(_filterToSnippets(command.NestedCommands(), currentCommandline, empty)); if (innerResults.Size() > 0) { From c58b823d1c19bf860347601c6d3c192af8ae9561 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Tue, 23 Jul 2024 10:30:00 -0500 Subject: [PATCH 10/11] format --- src/cascadia/TerminalApp/AppActionHandlers.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cascadia/TerminalApp/AppActionHandlers.cpp b/src/cascadia/TerminalApp/AppActionHandlers.cpp index 1625f1ca646..cf294fbd47d 100644 --- a/src/cascadia/TerminalApp/AppActionHandlers.cpp +++ b/src/cascadia/TerminalApp/AppActionHandlers.cpp @@ -1511,7 +1511,6 @@ namespace winrt::TerminalApp::implementation } } - co_await wil::resume_foreground(Dispatcher()); // Open the palette with all these commands in it. From 251720032099f35e3071c279e8cfee38e90165d0 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Tue, 23 Jul 2024 15:03:20 -0500 Subject: [PATCH 11/11] nits --- src/cascadia/TerminalSettingsModel/ActionMap.cpp | 9 +-------- src/cascadia/TerminalSettingsModel/Command.cpp | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/cascadia/TerminalSettingsModel/ActionMap.cpp b/src/cascadia/TerminalSettingsModel/ActionMap.cpp index 1943f31a4b2..6802c93087e 100644 --- a/src/cascadia/TerminalSettingsModel/ActionMap.cpp +++ b/src/cascadia/TerminalSettingsModel/ActionMap.cpp @@ -948,14 +948,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation { for (const auto& json : actions) { - const auto parsed = Command::FromSnippetJson(json); - // Skip over things that aren't snippets - if (parsed->ActionAndArgs().Action() != ShortcutAction::SendInput) - { - continue; - } - - result.push_back(*parsed); + result.push_back(*Command::FromSnippetJson(json)); } } return result; diff --git a/src/cascadia/TerminalSettingsModel/Command.cpp b/src/cascadia/TerminalSettingsModel/Command.cpp index 56b0205d344..ac66d188b9d 100644 --- a/src/cascadia/TerminalSettingsModel/Command.cpp +++ b/src/cascadia/TerminalSettingsModel/Command.cpp @@ -309,7 +309,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation IActionArgs args{ nullptr }; std::vector parseWarnings; std::tie(args, parseWarnings) = SendInputArgs::FromJson(json); - result->_ActionAndArgs = *winrt::make_self(action, args); + result->_ActionAndArgs = winrt::make(action, args); return result; }