Page MenuHomePhabricator

Links to line anchors of modules in Scribunto error popup do not jump to line of that Module's source code
Open, Needs TriagePublicBUG REPORT

Description

Scribunto error messages in English Wiktionary have a popup that appears when you click them. The popup contains more information on the error. Sometimes this involves a traceback.

When the traceback mentions a line in a Lua module on the wiki, it links to the module, with a link fragment containing the line number; for instance, currently in this edit, #mw-ce-l174 where 174 is the line of the module mentioned in that line of the traceback. If you click the link in the traceback, which takes you to the module, the fragment has no effect. This seems to happen whether or not CodeEditor is enabled.

Formerly, when you got to the module page, the textbox would be focused and the cursor would be placed at the beginning of the line mentioned in the link fragment. This was very helpful because you would be able to see the line mentioned without having to scroll down in the textbox or use the "jump to line" feature.

I don't recall exactly when this changed, but a year or more ago.

Reproduction: go to this edit, click the red Lua error to open a backtrace, then click the line of the backtrace that mentions a line of Module:debug (at the moment of writing, line 174). This should open Module:debug and scroll the page to the code editor and show that line in the code editor, but at the moment no scrolling of the page or the code editor happens.

Event Timeline

@Erutuon: Please provide a link that allows others to reproduce the problem. Thanks.

@Erutuon: Please provide a link that allows others to reproduce the problem. Thanks.

Added a link to https://en.wiktionary.org/wiki/Special:Permalink/54825976.

Aklapper renamed this task from Links to lines of modules in Scribunto error popup do not work to Links to line anchors of modules in Scribunto error popup only jump to top of that Module's source code.Oct 7 2019, 9:55 AM
Anomie added a subscriber: Anomie.

Without CodeEditor, there's probably no good way to make the anchor work. JS to do that seems outside the scope of Scribunto.

With CodeEditor, it looks like there's currently a race where WikiEditor is triggering the "doneInitialSections" event before CodeEditor registers for it, so CodeEditor never manages to register its hashchange listener.

Erutuon renamed this task from Links to line anchors of modules in Scribunto error popup only jump to top of that Module's source code to Links to line anchors of modules in Scribunto error popup do not jump to line of that Module's source code.Oct 7 2019, 4:39 PM

I renamed the task because for me, and presumably for others, the link doesn't jump to the top of the source code either. Perhaps something in my settings prevents the link from going to the top of the source code.

CCicalese_WMF claimed this task.
CCicalese_WMF added a subscriber: CCicalese_WMF.

Marking as Resolved as it is in the Done column. Feel free to reopen if there is remaining work.

I don't know why the task was marked as Done, but the bug remains for me at least.

Aklapper removed CCicalese_WMF as the assignee of this task.

I don't see what's done or resolved here, apart from an analysis (not: fix) by CPT, hence remopening

CCicalese_WMF added a subscriber: TheDJ.

@TheDJ Is this fixable in CodeEditor? @Erutuon more information to reproduce the error would be helpful. Untagging Platform Engineering, as this does not appear to be a core issue. Please retag if necessary.

The analysis by Anomie is correct:

With CodeEditor, it looks like there's currently a race where WikiEditor is triggering the "doneInitialSections" event before CodeEditor registers for it, so CodeEditor never manages to register its hashchange listener.

Note to self: https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/WikiEditor/+/591341/

@Erutuon more information to reproduce the error would be helpful.

I've added an explanation at the bottom of my original post which I hope is clearer.

Why is codeEditorMonitorFragment() attached to wikiEditor-toolbar-doneInitialSections in the first place? Why not simply execute it at the end of jquery.codeEditor.js along with setupCodeEditor()? (EDIT: I tried this and it didn't work either.)

(But now that T29531: Implement link anchors to line numbers on syntax-highlighted pages (e.g. .css, .js) is done, errors may simply link to action=view.)

I've modified MediaWiki:Scribunto-module-line on English Wiktionary to link to #L-<line_number> in action=view of the erroring module. That looks horrible in the JavaScript-generated backtrace (which shows the raw wikitext), but at least people can jump to one of the source lines mentioned in the backtrace now. I may rethink this and revert my edit.