From 628aa40f13e9bbd313b51ab625f193110aad8dd0 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 9 Aug 2026 04:20:20 -0300 Subject: Tab after a dot in insert mode lists what could go there --- test/lspfixture/dotcomplete.zig | 28 ++++++++++++++++++++++++++++ test/lspfixture/dothalf.zig | 24 ++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 test/lspfixture/dotcomplete.zig create mode 100644 test/lspfixture/dothalf.zig (limited to 'test/lspfixture') diff --git a/test/lspfixture/dotcomplete.zig b/test/lspfixture/dotcomplete.zig new file mode 100644 index 00000000..484f6b86 --- /dev/null +++ b/test/lspfixture/dotcomplete.zig @@ -0,0 +1,28 @@ +//! A file caught MID-KEYSTROKE, for the lspbench completion probe. Like +//! broken.zig it is NOT built and NOT imported by anything, and like broken.zig +//! its defect is the point. +//! +//! `Tab` after a `.` is the one language query whose normal input does not +//! parse: the user has typed the dot and nothing else, so `switch (s) { . }` +//! loses the entire switch to the parser's error recovery and every ancestor +//! an expected-type resolution needs goes with it. A probe pointed at a +//! FINISHED `.member` would exercise the resolution and none of the repair, +//! and would pass on a backend that cannot answer a real keypress at all. +//! +//! Nothing here comes from std, so what the probe checks does not encode this +//! machine's stdlib. The member names are nonsense words on purpose: they +//! appear on their DECLARATION lines and nowhere else, so a row containing one +//! can only have come from the enum's definition and never from the switch the +//! cursor is sitting in. +pub const Shade = enum { + verdigris, + cinnabar, + orpiment, +}; + +pub fn pick(s: Shade) u8 { + return switch (s) { + . + }; +} + diff --git a/test/lspfixture/dothalf.zig b/test/lspfixture/dothalf.zig new file mode 100644 index 00000000..69d407fa --- /dev/null +++ b/test/lspfixture/dothalf.zig @@ -0,0 +1,24 @@ +//! The other half of a real keypress, for the lspbench completion probe. Like +//! broken.zig and dotcomplete.zig it is NOT built and NOT imported by anything. +//! +//! dotcomplete.zig types its dot into a switch whose braces are already there, +//! which turns out to be the EASY half: the dot is the only thing wrong with +//! the file, so any repair at all makes the tree whole. Mid-typing a line is +//! short of its terminator as well, and `const z: Shade = .` is then exactly +//! ONE parse error whether a placeholder identifier is spliced in or not. A +//! repair chosen by counting parse errors therefore discards itself here, and +//! the feature silently only worked on finished syntax — which is what this +//! file exists to stop happening again. +//! +//! It is its own file rather than another function in dotcomplete.zig, and +//! that is load-bearing: Zig's error recovery runs FORWARD, so an unrepaired +//! break earlier in a file swallows the declaration the cursor is in. Only the +//! break at the cursor is repaired, so a fixture may hold only one. +pub const Shade = enum { + verdigris, + cinnabar, +}; + +pub fn unterminated() void { + const z: Shade = . +} -- cgit v1.3