Skip to content

Commit fb4e3e9

Browse files
committed
fix: run fish completion on fish 3.x and give Windows a native MCPP path
The fish adapter asked commandline for --tokens-expanded, a flag fish only gained in 4.0; the completion job's Ubuntu image ships fish 3.7, where the unknown flag left the word list empty and no candidate was produced. Ask for --tokenize (-o), which both lines accept and whose cut-at-cursor behaviour is the same. The Windows PowerShell job inherits MCPP from a Git Bash environment, so the value is /d/a/... rather than a native path and native Python resolved D:\d\a\... . Convert that spelling before resolving the binary.
1 parent d2d79f9 commit fb4e3e9

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

‎src/shell.cppm‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ compdef _mcpp_complete mcpp mcpp.exe
6666
)MCPP";
6767
if (shell == "fish") return R"MCPP(# mcpp completion; source this file from config.fish.
6868
function __mcpp_candidates
69-
set -l words (commandline -xpc)
69+
# --tokenize (-o) exists in fish 3.x; --tokens-expanded (-x) is 4.0+.
70+
set -l words (commandline -opc)
7071
set -l current (commandline -ct)
7172
set -l reply (command $words[1] __complete $words[2..-1] "__mcpp_word__$current" 2>/dev/null)
7273
if test "$reply[1]" = files

‎tests/scripts/test_shell_completion.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,15 @@
1111
import unittest
1212

1313

14+
def native_path(value):
15+
"""Make a path exported by Git Bash usable by native Windows Python."""
16+
if os.name == "nt" and value[:1] == "/" and value[2:3] == "/":
17+
return value[1].upper() + ":" + value[2:]
18+
return value
19+
20+
1421
ROOT = Path(__file__).resolve().parents[2]
15-
MCPP = Path(os.environ["MCPP"]).resolve() if os.environ.get("MCPP") else None
22+
MCPP = Path(native_path(os.environ["MCPP"])).resolve() if os.environ.get("MCPP") else None
1623

1724

1825
@unittest.skipUnless(MCPP, "set MCPP to a freshly built binary")

0 commit comments

Comments
 (0)