question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Line numbers in the code viewer

See original GitHub issue

I use https://runpkg.com sometimes to debug stack traces that point to my node_modules when I don’t have access to the actual node_modules folder. It would be really helpful if I could see line numbers in the code viewer.

Other related features I’d really appreciate:

  • Jump to line/column. I’d love to type in https://runpkg.com/follow-redirects/index.js:158:24 which comes from a stack trace and jump right there.
  • URL to share a specific line number or range of line numbers. When I’m debugging an issue for others I can then link to the actual problem code from runkg.com

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
VirtualDOMiniccommented, Jun 10, 2019

For a bit of fun, in the meantime you could do something like this to show line numbers:

document.querySelector("pre").innerHTML = 
document.querySelector("pre")
  .innerHTML.split(/\n/)
  .map((x, i) => `<span class="token line-number L${i+1}">${i+1}\t</span>${x}`)
  .join("\n")

…and if you wanted a function to then do the scrolling for you, you could do something like this, where 158 is the line number you want.

(function(lineNumber){
  document.querySelector(`.L${lineNumber}`).scrollIntoView();
  document.querySelector("article").scrollBy(0, -55);
})(158)

Definitely not proposing this as a long-term solution, but the snippet for showing line numbers might prove at least moderately useful for now

0reactions
lukejacksonncommented, Nov 23, 2019

This is done now, thanks to @alex-saunders 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Display line numbers for code - Visual Studio (Windows)
In this article​​ You can show or hide line numbers in your code. Here's how. On the menu bar, choose Tools > Options....
Read more >
Displaying line numbers - IBM
Select View > Active Code View from the menu bar. · To display line numbers, click the tab for the generated code and...
Read more >
visualstudio-docs/how-to-display-line-numbers-in-the-editor ...
You can show or hide line numbers in your code. Here's how. On the menu bar, choose Tools > Options. Expand the Text...
Read more >
VS Code tips: The Editor Line Numbers setting - YouTube
Today's VS Code setting: editor.lineNumbersConfigure how line numbers are displayed in text editors:• off — Hide line numbers.
Read more >
Line numbers in code viewer in Test Studio | Telerik Forums
Open the test file and click on 'View Entire Code Behind File' option. This will show the coded steps code in Code Viewer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found