Feature: show a window of a file or diff (lines a-b) that can grow in place

Aperta
#1,284 2 commenti 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

Start by reading the renderer code that builds and consumes FileDiffMetadata, then trace how it handles hunk context and syntax highlighting in unified and split views. The issue does not name specific files or tests, so locate those entry points and related tests first. Done means hosts can render and grow a partial file or diff window with correct line numbers and highlighting, without losing component state or hiding changes outside the window.

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

Descrizione

enhancement
Prerequisites
Proposal

Use case

We embed many small excerpts of code review diffs in written documents: "here are lines 120-140 of this file, and what changed in them". Each excerpt is a window: a contiguous range of lines from one file, or from one side of a diff. A reader can grow the window in place, a few lines at a time, at its top or bottom edge.

Needed from the renderer for each window:

  • Real line numbers, not numbering that restarts at 1.
  • Syntax highlighting as if the whole file were shown. A window that starts inside a block comment or template string should still look right.
  • Changes outside the window are simply not part of the view: no error, and no "N unmodified lines" separator that hides changed lines.
  • Growing the window doesn't remount the component or lose its state, in unified and split views.
  • Any change in or near the window can be shown, including added and deleted files.

Current behavior (1.7 beta)

When building FileDiffMetadata for a window, and there is a change below the window, rendering fails with trailing context mismatch, because whatever follows the last hunk is treated as the unchanged rest of both files.

When the first hunk doesn't reach back to line 1, rows can show the wrong lines' text or lose highlighting.
So today there's no supported way to say "this metadata describes only part of the diff".

Request

A supported way for a host to render part of a file or diff. It could be a small, general primitive that empowers users to build snippet experiences.

Motivation and context

Expandable snippets embedded in prose are generally useful for AI to explain code it has written, highlighting the most interesting parts.

We also have a page with all comments from code reviewers, each accompanied by the associated code snippet.

Lingua principale
TypeScript
Stelle
6.2k
Fork
226
Merge medio
1g 14h
PR unite (30g)
53

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 pierrecomputer/pierre

Tutte le issue di pierrecomputer/pierre

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.