Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add link to external editor to rescue view #46378

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Oct 29, 2022

  1. Add link to external editor to rescue view

    I don't know the official way to request a feature in RoR.  I hope
    this pull request is reasonably complete and acceptable.
    
    This is a somewhat trivial diff.  Currently, when an exception is
    thrown, a page is rendered and part of the page has the paths and line
    numbers from the exception stack.  The lines are clickable and when
    clicked, the upper section changes to show more context of the line in
    the original source code.
    
    The proposed change is to add an additional link whose text is the
    Unicode link symbol after the existing link.  The more common glyph
    was rejected by Unicode.
    
    The href for the link symbol comes from Ruby code that first checks,
    at render time, to see if ActionDispatch::DebugView#ext_editor is
    defined.  If it is, it is called passing the "frame".  Otherwise,
    ActionDispatch::DebugView#int_editor is called.
    
    int_editor creates a URL using the `file:` scheme.  While most
    browsers won't follow the link, it will show to the developer what is
    possible.  My example of ext_editor creates a URL using the `emacs:`
    scheme.
    
    I've added a tool tip to try and tell the developers how they can
    configure the URL to invoke their favorite editor.
    
    I thought the approach of checking to see if a method is defined
    and calling it would be preferred to having the user redefine the
    definition of an existing method.
    
    Another piece of work to do would be to add something like the sample
    I have to the templates so that config/initializers/debug_view.rb
    would be created when the Rails app is created.
    
    Having both links, the currently existing link that shows the code
    snippets and the new link that opens the file in the external editor,
    gives the users the best of both worlds.  They can view in the browser
    what happened and then click to get them placed in their favorite
    editor at the line number for the issue.
    
    The key here is "their favorite editor" can be customized to their
    liking via the ext_editor method.
    pedz committed Oct 29, 2022
    Configuration menu
    Copy the full SHA
    75fde78 View commit details
    Browse the repository at this point in the history