Question about displaying diff context #3088
Zak Siddiqui opened 1 week ago

In popular Git pagers such as Git-delta, it is able to display the context of the current lines being displayed, including the name of the function, the name of the class, and so on. However, OneDev does not natively do this. When I'm looking at a git diff, I can't tell which function the individual line changes are in. If there is no way to enable this, can we add this feature so that it's on by default?

Don't assume. Ask high-level clarifying questions if needed.

  • Numbered questions (1, 2, 3, etc)
  • Lettered answer options (A, B, C, etc)
  • Include a markdown table that contains the following for each option:
    • number (with an emoji that represents your recommended option)
    • Option short title
    • Explanation (don't assume my level of knowledge).
    • Pros (with relevant emojis)
    • Cons (with relevant emojis)
  • Service Desk commented 1 week ago

    There is currently no setting to enable enclosing class/function context in OneDev web diffs. OneDev computes and renders its own line-based diff blocks; it lets you expand surrounding unchanged lines, but it does not retain or display the section text found after a Git @@ ... @@ hunk header. Tools such as delta can show or restyle that section text from Git, so matching that behavior in the web UI requires a feature change.

    1. Which presentation should the feature use?
    NumberOption short titleExplanationProsCons
    1️⃣ ⭐Hunk context label (recommended)Show the nearest enclosing symbol, such as a class, method, or function, once at the start of each visible change block. This is closest to the familiar Git/delta hunk-header behavior.✅ Compact; ✅ familiar; ✅ works in unified and split views⚠️ The label can scroll out of view in a long change block; ⚠️ accuracy depends on language support
    2️⃣Sticky context breadcrumbKeep the current class/function context visible while scrolling through a file diff, updating it as the viewport enters another symbol.✅ Context remains visible; ✅ useful for large diffs⚠️ More UI complexity; ⚠️ needs clear behavior when old and new sides have different symbols
    3️⃣Both presentationsAdd hunk labels and also keep the active context visible while scrolling.✅ Most context; ✅ handles short and long change blocks⚠️ More visual clutter; ⚠️ largest implementation and maintenance cost

    Please reply with 1A, 1B, or 1C (or describe a different preference): A = option 1, B = option 2, C = option 3.

  • Robin Shen changed state to 'Closed' 1 week ago
    Previous Value Current Value
    Open
    Closed
1/1
Type
Question
Priority
Normal
Assignee
Labels
No labels
Issue Votes (0)
Watchers (3)
Reference
OD-3088
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover