From 90c93fba8c0f837cf6f014a410ebf860587cc86e Mon Sep 17 00:00:00 2001 From: Anatolii Hrynchuk Date: Wed, 18 Nov 2026 13:06:48 +0200 Subject: [PATCH] Prepare KSwitcher v0.6.119 Run local Files commands and resolve completion paths from the active pane. --- CMakeLists.txt | 2 +- FILES-UI.md | 9 ++++- Release/README.md | 8 ++++ Release/SHA256SUMS.txt | 2 +- Release/release-files.json | 80 +++++++++++++++++++------------------- resources/app.rc | 6 +-- src/files_main.cpp | 49 ++++++++++++++++------- src/update.h | 2 +- tests/files_activation.ps1 | 33 +++++++++++++++- 9 files changed, 127 insertions(+), 64 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f8e726d..e68af3d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.24) -project(KSwitcher VERSION 0.6.118 LANGUAGES CXX RC) +project(KSwitcher VERSION 0.6.119 LANGUAGES CXX RC) if(NOT WIN32) message(FATAL_ERROR "KSwitcher uses native Windows APIs") endif() diff --git a/FILES-UI.md b/FILES-UI.md index c3a0eac..bd5373d 100644 --- a/FILES-UI.md +++ b/FILES-UI.md @@ -129,14 +129,19 @@ Warning і початковий фокус на No. Enter передає порожній рядок у термінал. Якщо фокус у виводі термінала, Enter і Shift+Enter повертають його до командного рядка й виконують відповідну дію за тими самими правилами. + Локальна команда запускається в папці активної панелі, яку показано + перед командним рядком. Після перемикання панелі або переходу до іншої + папки наступна команда використовує нову папку навіть у вже відкритому + PowerShell. Якщо команда змінює папку (наприклад, через `cd`), панель + переходить до неї, якщо користувач за цей час не змінив її розташування. Під час запуску термінала область виводу має темне тло, поки WebView2 готує сторінку. Промпт і текст команди вирівняні по спільній базовій лінії. - Під час набору локальної команди над полем з’являються підказки PowerShell. Автодоповнення працює з відкритими й прихованими панелями (Ctrl+O). Список уточнюється після кожної зміни тексту й доповнює команди, параметри - та шляхи відносно робочої папки термінала або активної панелі до запуску - термінала. Після `cd ` список пропонує папки, + та шляхи відносно робочої папки активної панелі. + Після `cd ` список пропонує папки, а після вибору можна продовжити шлях через `\`, зокрема всередині лапок. Стрілки вгору й вниз вибирають підказку. Tab вставляє вибрану або першу, Enter вставляє виділену, а клік вставляє підказку під вказівником. diff --git a/Release/README.md b/Release/README.md index b8f63b4..9ff91a5 100644 --- a/Release/README.md +++ b/Release/README.md @@ -1,5 +1,13 @@ # Latest Windows release +## v0.6.119 — 2026-11-18 + +KSwitcher Files runs local commands in the folder shown at the command prompt. After switching panes or opening a different folder, commands such as `git clone` and relative path suggestions use that folder in the same PowerShell session. + +**Українською.** + +KSwitcher Files запускає локальні команди в папці, показаній перед командним рядком. Після перемикання панелі або переходу до іншої папки команди на кшталт `git clone` і підказки відносних шляхів використовують цю папку в тій самій сесії PowerShell. + ## v0.6.118 — 2026-11-18 - **Shift+F11** opens a side-by-side comparison of two selected text files from local, LAN or FTP panes. The comparison has its own taskbar button, a movable divider, a native toolbar, **F7/F8** change navigation, and **Ctrl+wheel** text zoom. The shortcut, font and colors are configurable in **Options → File comparison**. diff --git a/Release/SHA256SUMS.txt b/Release/SHA256SUMS.txt index a8877e3..d5ca806 100644 --- a/Release/SHA256SUMS.txt +++ b/Release/SHA256SUMS.txt @@ -1 +1 @@ -b7e420509b1ed00bb5c1898fa25c3965fd49ed9d2e9bd85fddcb5149bb7166be KSwitcher-win-x64.zip +566cda1b26bbc5980e3e19f804ae500bf029fe6f5a503cfd609be6f6ad4409ea KSwitcher-win-x64.zip diff --git a/Release/release-files.json b/Release/release-files.json index 00a008b..d09d488 100644 --- a/Release/release-files.json +++ b/Release/release-files.json @@ -1,166 +1,166 @@ { + "version": "0.6.119", + "schema": 1, "files": [ { - "path": "KSwitcher.exe", "size": 2479104, - "sha256": "d6f931814b40f1e915f4762464195919f282be0bc7d349820509d8504de3e702" + "path": "KSwitcher.exe", + "sha256": "e6b98679ac0a460e42ec9f593e88cc802cedaaaf887bce79c3f8577419143aa1" }, { - "path": "KSwitcher.Config.exe", "size": 2458112, - "sha256": "0465d7edcd069767292d2395961984973613ae1df484394c967a7d5996855668" + "path": "KSwitcher.Config.exe", + "sha256": "43e4ea0d087d70658fd2cca47b2f06b919eb86acc65dce1afa7db1e02cbdcded" }, { - "path": "KSwitcher.Screenshot.exe", "size": 3060224, - "sha256": "bb11400e632aafdc7048737e0b68322f7a37e359452fce87471f70dbd5bde7ed" + "path": "KSwitcher.Screenshot.exe", + "sha256": "9b791b2dbf623f50ab92cde4017b07c9f8df4bbb7ac3526d0d18e0d770061f43" }, { + "size": 4370944, "path": "KSwitcher.Files.exe", - "size": 4368896, - "sha256": "2e59662282a99b5ab42e3cef80ca554470f6d2d9f7e8e7c856d27a6ff9529b9e" + "sha256": "e44a923d3e686e0e273e6dd167f6bd66dafd66e2870b4950fcbd8824d286a61d" }, { - "path": "WebView2Loader.dll", "size": 194912, + "path": "WebView2Loader.dll", "sha256": "d3fce90bdeecb08596e377dea6a316354dd8949e32ff09b89d51be00c14e21b6" }, { - "path": "terminal/addon-fit-LICENSE.txt", "size": 1103, + "path": "terminal/addon-fit-LICENSE.txt", "sha256": "e256f01188af527e4d06d21d06fbf785ae9c50d4b328bf03cbe0ba7f0aa4228f" }, { - "path": "terminal/addon-fit.js", "size": 1521, + "path": "terminal/addon-fit.js", "sha256": "ba3ea256ce0620a0992a197d6c9baea64823fc93d8da07a9e366ca9943c18527" }, { - "path": "terminal/index.html", "size": 527, + "path": "terminal/index.html", "sha256": "084d97a727b778fb10d31adcd557ee7840a38377ed60e0ef0f3ece93b349b1ef" }, { - "path": "terminal/markdown-it-LICENSE.txt", "size": 1073, + "path": "terminal/markdown-it-LICENSE.txt", "sha256": "792c48c5a849a15fdf9e37e8bcf9e6d1dd13b32b46c642a748a0a46a9919d473" }, { - "path": "terminal/markdown-it.js", "size": 100786, + "path": "terminal/markdown-it.js", "sha256": "391f2aa638e75e6c7859d0a5c5650ef0956722a45998f17e05b83bc655778e1e" }, { - "path": "terminal/markdown.html", "size": 3635, + "path": "terminal/markdown.html", "sha256": "8268f55e8642034efa5a762cbd65d02a1d416aea9e777e0fe30a7e916ae3ee79" }, { - "path": "terminal/markdown.js", "size": 16944, + "path": "terminal/markdown.js", "sha256": "4c68dff619cf248f6bd32b09a45458675c22341892dc377204e46c2f4fd562f8" }, { - "path": "terminal/mermaid-LICENSE.txt", "size": 1089, + "path": "terminal/mermaid-LICENSE.txt", "sha256": "ec9fb67dcb25eccc416ed56e1aab819222c805a2a4bfe4cb19e7556bf2ffde80" }, { - "path": "terminal/mermaid.js", "size": 5537838, + "path": "terminal/mermaid.js", "sha256": "336df803d87a38b70a01e736e666c8f7601d2ce42f5e47c8fafe5d721074b9a3" }, { - "path": "terminal/terminal.js", "size": 5065, + "path": "terminal/terminal.js", "sha256": "8268049507da54079422db2b4d90b41cd0a1e99b5946b675173ea3543de27f0b" }, { - "path": "terminal/xterm-LICENSE.txt", "size": 1261, + "path": "terminal/xterm-LICENSE.txt", "sha256": "b569f629d00f2626a8100df2a1798210535621e42164dfd426a6fe5aac7b0ccd" }, { - "path": "terminal/xterm.css", "size": 7112, + "path": "terminal/xterm.css", "sha256": "854a7c0fb70e8b1a083c16797ab827299fb18744f5ad34f227b48337e33293c6" }, { - "path": "terminal/xterm.js", "size": 488663, + "path": "terminal/xterm.js", "sha256": "14903579ff54664cd72f8e8699e6961a6272c21863ec1c3b118cdc8af5d4a972" }, { - "path": "LICENSE", "size": 4401, + "path": "LICENSE", "sha256": "d3c81140cce01c26bf6cbf52aa40e0825e1fa35b9a91d1387170a65d2597082c" }, { - "path": "json-LICENSE.txt", "size": 1096, + "path": "json-LICENSE.txt", "sha256": "61e08da79c44061654015ce6b0c4061c23ee1dd18237fbf09e9bfda3c0ea2831" }, { - "path": "files-text-license.txt", "size": 883, + "path": "files-text-license.txt", "sha256": "185c5a37521316e940ead89cbf0b1ba5862d810c7c966e6c6a14a4a515b23625" }, { - "path": "README.md", "size": 95317, + "path": "README.md", "sha256": "ea5016c6fa29a98bf9ebf103fcf27f1be091842ad3228b167d18b053fda767d8" }, { - "path": "LAN-PREVIEW.md", "size": 11577, + "path": "LAN-PREVIEW.md", "sha256": "1233d6a0ed76564dd034f178a9f65db076244a819137f74dc9f2c27df9d3c930" }, { - "path": "dictionaries/en.txt", "size": 732485, + "path": "dictionaries/en.txt", "sha256": "d0c022b27b9fbc2ff7b6b8bec723cc1adc4eef517202f9ff77eed5d8bea3acb9" }, { - "path": "dictionaries/LICENSE-CC-BY-SA-4.0.txt", "size": 20566, + "path": "dictionaries/LICENSE-CC-BY-SA-4.0.txt", "sha256": "0bdfb0201d1803634f268cdff0993b8349d2c70e956a06dbb667c8dd65254ec5" }, { - "path": "dictionaries/README.md", "size": 2265, + "path": "dictionaries/README.md", "sha256": "3017bf44d3be9d9dfab21bd6778aa52b7947e61acf9ce2bc86b41d6e949ac311" }, { - "path": "dictionaries/ru.txt", "size": 1109134, + "path": "dictionaries/ru.txt", "sha256": "80e6b6a27815973535f7facb636c597eb845dfee45cfabfc4e9b3341b9332849" }, { - "path": "dictionaries/sources.json", "size": 1280, + "path": "dictionaries/sources.json", "sha256": "98e5b3fe7304e37705c9e5ff48b0b399ccb16e806736d21f09921b99e5f2a408" }, { - "path": "dictionaries/uk.txt", "size": 940799, + "path": "dictionaries/uk.txt", "sha256": "d30e990d6ec2983c04f3644a3c61c6c668e8c542323f5931916fdd55b916eebf" }, { - "path": "tools/README.txt", "size": 993, + "path": "tools/README.txt", "sha256": "a34b5161a8315af037e1ec71d816bfc688f7c364141d4ee2347cf0515ef0c82a" }, { + "size": 133120, "path": "tools/StayHere.exe", - "size": 540583, - "sha256": "bb595202cc4749f3c0fe47adc92d4b02a174abeb5765e493673de9f5e070251c" + "sha256": "d689b74a0c5ba018d3f26eb32c4fab88a8404627ee69be1e326d60b1167b5667" }, { - "path": "tools/StayHere-README.md", "size": 2796, + "path": "tools/StayHere-README.md", "sha256": "ba214e2aca7405e698b3ab21ceb1f41ce088edd996b3e30e4a9d58ff496f9413" } - ], - "version": "0.6.118", - "schema": 1 + ] } diff --git a/resources/app.rc b/resources/app.rc index e8deed9..0d048f5 100644 --- a/resources/app.rc +++ b/resources/app.rc @@ -9,8 +9,8 @@ IDC_SCREENSHOT_PENCIL CURSOR "icons/lucide/pencil.cur" 1 RT_MANIFEST "app.manifest" 201 RCDATA "update.ps1" 1 VERSIONINFO - FILEVERSION 0,6,118,0 - PRODUCTVERSION 0,6,118,0 + FILEVERSION 0,6,119,0 + PRODUCTVERSION 0,6,119,0 FILEOS VOS_NT_WINDOWS32 FILETYPE VFT_APP BEGIN @@ -20,7 +20,7 @@ BEGIN BEGIN VALUE "FileDescription", "KSwitcher — native keyboard and clipboard utility" VALUE "ProductName", "KSwitcher" - VALUE "FileVersion", "0.6.118" + VALUE "FileVersion", "0.6.119" END END BLOCK "VarFileInfo" diff --git a/src/files_main.cpp b/src/files_main.cpp index 88bfef0..49d1089 100644 --- a/src/files_main.cpp +++ b/src/files_main.cpp @@ -441,7 +441,12 @@ HWND terminalInput{},terminalOutput{},terminalPrompt{}; constexpr UINT_PTR terminalTimer=2; constexpr UINT_PTR directoryWatchTimer=4; bool terminalVisible{}; -std::deque terminalCommandPanels; +struct TerminalCommandContext +{ + int panel=-1; + fs::path directory; +}; +std::deque terminalCommands; std::wstring terminalDirectory; int terminalRows{}; struct CommandEntry { std::wstring date, command; }; @@ -1061,8 +1066,8 @@ void swapPanels(HWND window) // Move the controls with their contents to retain the cursor and scroll position. std::swap(panels[0],panels[1]); active=1-active; - for(auto &panel:terminalCommandPanels) - if(panel>=0) panel=1-panel; + for(auto &command:terminalCommands) + if(command.panel>=0) command.panel=1-command.panel; for(int i=0;i<2;++i) { const auto &panel=panels[i]; @@ -1346,7 +1351,7 @@ std::optional currentCompletionQuery() if(!first || first!=last) return {}; std::wstring directory; if(!panels[active].peer && !panels[active].ftp) - directory=terminal.alive() && !terminalDirectory.empty()?terminalDirectory:panels[active].directory.native(); + directory=panels[active].directory.native(); return CompletionQuery{std::move(line),std::move(directory),first}; } @@ -1674,14 +1679,19 @@ bool ensureTerminalView(HWND owner) else if(message.starts_with(L"directory:")) { const auto directory=message.substr(10); - if(!terminalCommandPanels.empty()) + if(!terminalCommands.empty()) { - const int panel=terminalCommandPanels.front(); - terminalCommandPanels.pop_front(); - std::error_code error; - if(panel>=0 && !panels[panel].peer && directory!=terminalDirectory && - !directory.empty() && fs::is_directory(directory,error)) - open(panels[panel],directory,false); + const auto command=std::move(terminalCommands.front()); + terminalCommands.pop_front(); + if(command.panel>=0 && !directory.empty() && directory!=command.directory.native()) + { + auto &panel=panels[command.panel]; + std::error_code error; + if(!panel.peer && !panel.ftp && panel.directory==command.directory && + (!panel.scanRequest || panel.scanRequest->directory==command.directory) && + fs::is_directory(directory,error)) + open(panel,directory,false); + } } terminalDirectory=directory; } @@ -1733,8 +1743,8 @@ bool startTerminal(HWND owner,const fs::path &directory) if(!ensureTerminalView(owner)) return false; if(terminal.start(directory.c_str(),terminalSize)) { - terminalCommandPanels={-1}; - terminalDirectory.clear(); + terminalCommands={{}}; + terminalDirectory=directory.native(); return true; } setStatus(L"Could not start PowerShell."); @@ -1835,12 +1845,21 @@ bool submitTerminalCommand(const Panel &panel,const std::wstring &value) return true; } if(!startTerminal(owner,panel.directory)) return false; - if(!terminal.write(value+L"\r")) + // Use the directory displayed by the panel at submission time. A queued + // command may change location before PowerShell gets to this input. + const bool hasCommand=value.find_first_not_of(L" \t\r\n")!=value.npos; + std::wstring input; + if(hasCommand && (terminalDirectory!=panel.directory.native() || + std::any_of(terminalCommands.begin(),terminalCommands.end(), + [](const auto &command){ return command.panel>=0; }))) + input=L"try { Microsoft.PowerShell.Management\\Set-Location -LiteralPath "+ + powerShellPath(panel.directory)+L" -ErrorAction Stop } catch { Write-Error $_; return }; "; + if(!terminal.write(input+value+L"\r")) { setStatus(L"Could not send PowerShell input."); return false; } - terminalCommandPanels.push_back(static_cast(&panel-panels)); + terminalCommands.push_back({hasCommand?static_cast(&panel-panels):-1,panel.directory}); return true; } diff --git a/src/update.h b/src/update.h index f6c7afb..ee4f207 100644 --- a/src/update.h +++ b/src/update.h @@ -2,7 +2,7 @@ #include "platform.h" namespace ks { -inline constexpr wchar_t AppVersion[] = L"0.6.118"; +inline constexpr wchar_t AppVersion[] = L"0.6.119"; inline constexpr UINT UpdateMessage = WM_APP + 7; inline constexpr UINT UpdateCheckIntervalMs = 6 * 60 * 60 * 1000; inline constexpr UINT UpdateNotificationRetryMs = 5 * 60 * 1000; diff --git a/tests/files_activation.ps1 b/tests/files_activation.ps1 index b15d547..4959033 100644 --- a/tests/files_activation.ps1 +++ b/tests/files_activation.ps1 @@ -460,6 +460,34 @@ function startTerminalFixture() { ([IO.File]::ReadAllLines($listing) -ccontains 'zzzz-dir-second') } Write-Output 'Verified repeated dir commands in the same terminal with file panes hidden and visible.' + $rightChild = Join-Path $rightDir "Command's [folder]" + [void][IO.Directory]::CreateDirectory($rightChild) + $childRow = "[$([IO.Path]::GetFileName($rightChild))]" + Wait-Until 'new folder in the right panel' { (Find-Row $right $childRow) -ge 0 } + $keys.SendKeys('{TAB}') + Send-InteractiveTerminal 'cmd /d /c "cd > panel-cwd.txt"' + Wait-Until 'native command running in the newly active right panel' { + (Test-Path -LiteralPath (Join-Path $rightDir 'panel-cwd.txt')) -and + (Find-Row $right 'panel-cwd.txt') -ge 0 + } + [void][FilesActivationUi]::Send($right, 0x186, [IntPtr](Find-Row $right $childRow), [IntPtr]::Zero) + Press-Enter $inputBox + $rightPath = [FilesActivationUi]::GetDlgItem($window, 143) + Wait-Until 'navigation to the right panel subfolder' { (Read-Text $rightPath) -ceq $rightChild } + Send-InteractiveTerminal 'cmd /d /c "cd > child-cwd.txt"' + Wait-Until 'native command running in the navigated folder' { + (Test-Path -LiteralPath (Join-Path $rightChild 'child-cwd.txt')) -and + (Find-Row $right 'child-cwd.txt') -ge 0 + } + Send-InteractiveTerminal 'cd ..' + Wait-Until 'PowerShell cd navigating the right panel' { (Find-Row $right 'panel-cwd.txt') -ge 0 } + $keys.SendKeys('{TAB}') + Send-InteractiveTerminal 'cmd /d /c "cd > left-cwd.txt"' + Wait-Until 'native command running back in the left panel' { + (Test-Path -LiteralPath (Join-Path $leftDir 'left-cwd.txt')) -and + (Find-Row $left 'left-cwd.txt') -ge 0 + } + Write-Output 'Verified native commands follow panel switches and folder navigation in the same PowerShell session.' $marker=Join-Path $root 'webview-enter.txt' $command="[IO.File]::AppendAllText('$($marker.Replace("'","''"))','executed')" [void][FilesActivationUi]::Write($inputBox,0x0C,[IntPtr]::Zero,$command) @@ -470,7 +498,10 @@ function startTerminalFixture() { !(Read-Text $inputBox) } Write-Output 'Verified Enter from the terminal WebView runs the command exactly once.' - Select-Row $left '[Test folder]' + # The left panel is already active after the working-directory check. + $folderRow = Find-Row $left '[Test folder]' + if ($folderRow -lt 0) { throw 'Missing folder for the terminal clipboard check.' } + [void][FilesActivationUi]::Send($left, 0x186, [IntPtr]$folderRow, [IntPtr]::Zero) $outputSelection = 'terminal-output-copy-fixture' Send-InteractiveTerminal "Write-Output '$outputSelection'" Wait-Until 'output selection fixture command submitted' { !(Read-Text $inputBox) }