Port completion popup window from upstream getline.cs - #2
Open
vbfox wants to merge 3 commits into
Open
Conversation
3 tasks
Ports mono/mono commit a7a4958 ("Add support for completion popup
windows") plus its two follow-up fixes (642b064, f91bb07), which never
made it into this F# port:
- CompletionState renders an actual popup window below the cursor
instead of dumping all matches as flat text.
- GetLineSettings.HeuristicsMode ("csharp") triggers completion
automatically (e.g. on '.') without waiting for Tab.
- Up/Down (and Ctrl+P/Ctrl+N) navigate the popup instead of history
while it's open; Escape closes it; most other edits close it
automatically (Handler now carries a ResetCompletion flag, mirroring
upstream's per-key `resetCompletion` parameter).
- CmdDone inserts the highlighted completion instead of submitting the
line when the popup is open.
Folded directly into the initial implementation rather than ported
bug-for-bug:
- 642b064's top_item scroll fix (`selected - top >= height`, not
`selected + top >= height`).
- f91bb07's HideCompletions() after auto-inserting a single match.
Also found and fixed two bugs while rewriting the common-prefix
matching logic that this feature reuses (present in the existing F#
port, not upstream): a missing loop increment that could hang
indefinitely comparing multiple completions sharing a prefix, and a
missing short-circuit that could index a shorter string out of bounds
(upstream avoids this via `goto`, which the original transcription
didn't replicate).
Adds a BlackFox.FsGetLine.Tests project (Expecto, matching FoxSharp's
convention) covering the pure logic that's actually testable without a
real console: CompletionState's popup scrolling math (including a
regression test for the 642b064 fix), the common-prefix matching fix,
and the C# dot-heuristic. Wired into the FAKE build as a RunTests task
that CI now depends on (previously a `DoNothing` placeholder).
Verified interactively by driving TestApp under a pty: Tab/arrow-key
popup navigation, Escape-to-close, and the heuristic auto-trigger on
'.' all work end to end with no exceptions.
vbfox
force-pushed
the
claude/port-completion-popup
branch
from
July 26, 2026 23:52
1058a50 to
d4da07c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ports the last cluster of upstream changes to
mcs/tools/csharp/getline.cs(Jan–Mar 2016), which predate this F# port and were never carried over:a7a4958— "Add support for completion popup windows" (the core feature)642b064— fix thetop_itemscroll logic in the popupf91bb07— callHideCompletions()after auto-inserting a single matchaee167f— demo update showing off the new heuristics modeWhat changed
CompletionStatenow renders an actual popup window below the cursor instead of dumping every match as flat text.GetLineSettings.HeuristicsMode(Some "csharp") triggers completion automatically (e.g. on.) without waiting for Tab.Handlernow carries aResetCompletionflag, mirroring upstream's per-keyresetCompletionparameter.CmdDone(Enter) inserts the highlighted completion instead of submitting the line when the popup is open.642b064,f91bb07) are folded directly into the initial implementation rather than ported bug-for-bug.TestApp's demo now setsHeuristicsModeand shows a popup automatically when typing., peraee167f.Bugs found & fixed along the way
While rewriting the common-prefix matching logic that this feature reuses, found two bugs in the existing F# port (not present upstream):
goto mismatch, which the original transcription into F# didn't replicate).Both are covered by regression tests (see below) — I confirmed each actually reproduces the original bug (hang / wrong result) by temporarily reverting the fix and re-running the suite.
Tests
Upstream
getline.cshas no test directory of its own, so there was nothing to port there. Added aBlackFox.FsGetLine.Testsproject (Expecto, matching the convention inBlackFox/FoxSharp) covering what's actually testable without a real interactive console —Console.ReadKey/cursor APIs make the main edit loop impractical to unit test:CompletionState's popup scrolling math, including a regression test that fails under the pre-642b064formulaWired into the FAKE build as a
RunTeststask thatCInow depends on (previously aDoNothingplaceholder in the oldbuild.fsx).Test plan
dotnet buildon the full solution./build.sh CI(restore → build → run tests → pack) succeeds locally, all 23 tests passtimeout)TestAppunder a real pty: Tab-triggered popup, arrow-key navigation, Escape-to-close, and the heuristic auto-trigger on.all work end to end with no exceptionsGenerated by Claude Code