Inline suggestion (ghost text) rendering primitive

Aperta
#124 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
swift
Ambito
desktop, devtools

Direzione di ricerca

Inizia da CodeEditTextView e ispeziona la geometria del caret e il percorso di layout/rendering; l’issue non indica alcun file né alcun target di test. Esegui la suite di test esistente xcodebuild clean test e SwiftLint, quindi verifica che l’InlineSuggestion API esegua il rendering di overlay su una o più righe senza modificare textStorage o lo stato di modifica.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Description

Add a low-level rendering primitive to CodeEditTextView for inline "ghost text" suggestions: text drawn after the caret that previews content the user has not typed yet (the same UI pattern as GitHub Copilot, Xcode predictive completion, and similar inline AI suggestions).

The proposed API is small and rendering-only:

  • A InlineSuggestion value type (a document offset plus the text to show, which may be multi-line).
  • TextView.setInlineSuggestion(_:at:), TextView.setInlineSuggestion(_:) (anchored at the primary caret), and TextView.clearInlineSuggestion().

Key design point: a suggestion is purely a rendering hint. It is drawn as a sibling overlay anchored at the caret and never mutates textStorage or shifts real text layout, so it cannot corrupt the document or interfere with editing, undo, or selection. This keeps the primitive safe and makes it a clean foundation that higher layers can drive.

Alternatives Considered
  • Inserting the suggestion as real (styled) text and removing it on reject. Rejected because it mutates the text storage, pollutes undo, and risks desyncing layout and selection.
  • Building the feature entirely in a downstream package. Rejected because the caret geometry and layout information needed to position ghost text correctly live in CodeEditTextView, so the rendering primitive belongs here. Higher-level packages should only decide what text to show and when.
Additional Context

This is intended as the foundation for native inline AI completions (for example GitHub Copilot) in the CodeEdit stack: CodeEditTextView provides the rendering primitive, CodeEditSourceEditor coordinates request/accept/dismiss, and CodeEdit wires up the provider. This issue covers only the CodeEditTextView rendering layer.

I have a working, documented implementation with unit tests (overlay rendering, multi-line suggestions, and a check that the suggestion never mutates text storage). It builds and tests pass via xcodebuild ... clean test, and SwiftLint is clean. I am happy to open it as a PR for review. Would the maintainers welcome this in CodeEditTextView?

Screenshots

This layer is a non-visual API primitive; the user-visible ghost text appears once a higher layer drives it. The rendered result can be shown in the downstream CodeEditSourceEditor / CodeEdit integration.

Lingua principale
Swift
Stelle
182
Fork
57
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di CodeEditApp/CodeEditTextView

Tutte le issue di CodeEditApp/CodeEditTextView

Issue simili

Altre issue su Swift

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.