fix(pi-fff): make FffEditor safe under composability subclassing#436
Merged
dmtrKovalenko merged 1 commit intodmtrKovalenko:mainfrom May 2, 2026
Conversation
When pi-vim or pi-image-attachments wrap a previously-installed editor by extracting `probe.constructor` and constructing `new SubClass(tui, theme, keybindings)`, the 4th argument FffEditor relied on for `getMentionItems` gets dropped. The mention provider closes over `undefined` and throws `TypeError: getItems is not a function` the first time the user types `@`. Move the FffEditor class definition inside fffExtension() so the override captures `getMentionItems` via closure rather than via a constructor parameter. The factory now matches the standard `(tui, theme, keybindings)` shape, so any wrapper that subclasses FffEditor inherits a working mention provider regardless of construction args. Refs: badlogic/pi-mono#3935
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.
Problem
When another extension installs a custom editor on top of
pi-fffusing the composability pattern from pi-mono#3935, typing@to trigger file-mention autocomplete throws:Confirmed against
pi-vimand@jordyvd/pi-image-attachments.Cause
pi-fff's factory took 4 args:Wrapping extensions probe the previous factory, extract
probe.constructor, and constructnew Composed(tui, theme, kb)with only 3 args.FffEditor.getMentionItemsbecomesundefined. WhensetAutocompleteProviderruns,createFffMentionProvider(undefined)closes overgetItems = undefined— the user's first@press then throws.Fix
Move the
FffEditorclass definition insidefffExtension()and capturegetMentionItemsvia closure instead of through a constructor parameter. The factory now matches the standard(tui, theme, keybindings)shape, so any wrapper that subclassesFffEditorinherits a working mention provider regardless of how it constructs the instance.Verification
Reproduced the failure end-to-end with
pi-image-attachments's probe-and-subclass pattern against the unpatchedFffEditor, and confirmed the patched class returns suggestions correctly under the same scenario:biome checkreports the same 2 errors / 1 warning asmain(both pre-existing, unrelated).Compat
Public surface unchanged: factory signature, class name, mode behavior, all tools and commands identical. Pure internal refactor.