Community Wishlist Survey 2019/Editing/Include section name in the diff

Include section name in the diff

  • Problem: When reading the revision diff, mostly it is hard to understand, which part of the page the diff line belongs to, because line number does not help so much - there is no line numbering in view mode.
  • Who would benefit: Everyone who opens page diffs.
  • Proposed solution: Regularly the differ does not show the changed line only, but also a line before and a line after, with no changes. I propose to show also the line with the most bottom subsection name the changed line belongs to, on both sides, as is, with equality signs. It's just one more line, but it will help to know exactly where you are. If there are many changes in the same subsection, the name will show only once, of course. This way the diff will be just a little longer - because section names are always shorter than regular lines and take less vertical space, but much more useful. Now we should copy all the time some part of changed line and search it using the browser searching mechanism.
  • More comments: There are two possibilities for using this feature - articles and talk pages, including forums as village pump, and it will help in both.


  • I like it. It can be a possibility to infer the section automatically or in case the user is editing a section already infer a better section if there is one that's deeper than the one that's being edited. Dixtosa (talk) 11:41, 30 October 2018 (UTC)[reply]
  • Agreed, If there is any value to line numbers it escapes me. This would be useful · · · Peter (Southwood) (talk): 11:48, 30 October 2018 (UTC)[reply]
  • Maybe changing UI it's a better way. — The preceding unsigned comment was added by Talueses (talk)
    Maybe indeed, but as the change is smaller, it has more chances to be implemented. IKhitron (talk) 21:08, 31 October 2018 (UTC)[reply]
  • I like this solution, it gives more context.   — Jeff G. ツ please ping or talk to me 03:03, 11 November 2018 (UTC)[reply]
  • IKhitron, would this be implemented instead of line numbers, or in addition to them? I support this solution, but I think line numbers should be kept as well, for they are very useful on CSS and JavaScript files' diffs. Guycn2 · ☎‏ 05:55, 17 November 2018 (UTC)[reply]
    Line numbers besides 1-3 have no value, there is no real connection between them and the place in the article, if there are infoboxes, galleries and such in the article, or even lines, that are connected into one paragraph without any indication in the text. Something that can really be seen in the article would be very helpful. I'd say: instead, but if someone sees any value in line numbers (I can't come up with a reason now), you can as well leave those. Grüße vom Sänger ♫(Reden) 11:24, 17 November 2018 (UTC)[reply]
    Hi, Guy. I really do not care. I can thing about another need of numbers - for example, if you see in diff lines 351 and 353 you can guess they are close. But it isn't so important, and isn't part of this proposal. IKhitron (talk) 14:40, 17 November 2018 (UTC)[reply]
  • Regarding the UI, I would suggest taking inspiration from the functionality (but not the formatting) for displaying context in source code diffs formatted as standard GNU diffutils patches (which is also the Git diff format). There, the context (function heading) is displayed along with the affected line numbers at the start of each chunk. Here's an example:
diff --git a/gtk/gtkmenushell.c b/gtk/gtkmenushell.c
index 4788590..cb94c64 100644
--- a/gtk/gtkmenushell.c
+++ b/gtk/gtkmenushell.c
@@ -585,18 +585,45 @@ gtk_menu_shell_button_press (GtkWidget      *widget,

   if (!menu_shell->active || !menu_shell->button)
-      _gtk_menu_shell_activate (menu_shell);
+      gboolean initially_active = menu_shell->active;

diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 58ce2db..921c22a 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -2443,6 +2443,13 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                                                               0.0, 1.0, 0.04,

+  gtk_widget_class_install_style_property (klass,
+                                           g_param_spec_boolean ("window-dragging",
In the sample above, the first chunk:
@@ -585,18 +585,45 @@ gtk_menu_shell_button_press (GtkWidget      *widget,
modifies 18 lines of the gtk_menu_shell_button_press() function, starting at line 585, and the result is 45 lines long starting at line 585 in the output file. (I've trimmed the diff length so those counts aren't accurate.) The detailed line numbering would be overkill for us, but the function heading represents the equivalent context to our section headings.
So instead of adding the section line into to the diff output (when it may be pretty far from the chunk being displayed), and rather than replacing the line numbers, I suggest the section title be shown following the line number at each diff chunk, even where it's redundant with the previous chunk(s). (If it's on the same line as the line#, it's not taking up any extra space anyway.) My edit here might be preceded with
Line 22: ===Discussion===
in the diff view. -- FeRDNYC (talk) 15:51, 17 November 2018 (UTC)[reply]
I still don't get it, what this line numbers are good for at all, except in some very special outliers like .css or .js pages. Nobody can see and follow them in any article that if bigger then a stub. Grüße vom Sänger ♫(Reden) 17:39, 17 November 2018 (UTC)[reply]
One can use CSS to completely remove the line numbers, but this unfortunately no longer clearly separates updates to different parts of the page. To do this
  1. Go to Special:Preferences, tab Appearance.
  2. Choose one of the Custom CSS links, which will be red if you have not yet used it, and create / edit that sub-page of your user-page.
  3. Add .diff-lineno { display: none; }.
PJTraill (talk) 11:41, 27 November 2018 (UTC)[reply]
If this really is an answer to me: Lines are quite useless on every page besides the very few .js and .css pages, where they might stay. But no indication at all where this diff is in the article is even worse. So as log as there is no appropriate solution, I'll stick to the numbers, very little use but better than nothing at all. Grüße vom Sänger ♫(Reden) 12:09, 30 November 2018 (UTC)[reply]
Hello, Dixtosa, Peter (Southwood) and Guycn2. Please let me remind you that you expressed an opinion about the proposal in the discussion section, but still did not vote. If you still have on opinion, I'll be glad if you add it in the voting section, by support or oppose templates, depends on what do you think now. Thank you. IKhitron (talk) 19:40, 27 November 2018 (UTC)[reply]
Done. Guycn2 · ☎‏ 12:24, 29 November 2018 (UTC)[reply]