Allow linking to file lines
Supported formats: "L12" for single lines and "L12-34" for multiple lines
This commit is contained in:
parent
45dcb1b5c4
commit
c42ada9bee
5 changed files with 174 additions and 194 deletions
|
@ -35,3 +35,22 @@ $ ->
|
|||
state = History.getState()
|
||||
window.ajaxGet(state.url)
|
||||
)(window)
|
||||
|
||||
# See if there are lines selected
|
||||
# "#L12" and "#L34-56" supported
|
||||
highlightBlobLines = ->
|
||||
if window.location.hash isnt ""
|
||||
matches = window.location.hash.match /\#L(\d+)(\-(\d+))?/
|
||||
first_line = parseInt matches[1]
|
||||
last_line = parseInt matches[3]
|
||||
|
||||
unless isNaN first_line
|
||||
last_line = first_line if isNaN last_line
|
||||
$("#tree-content-holder .highlight .line").removeClass("hll")
|
||||
$("#LC#{line}").addClass("hll") for line in [first_line..last_line]
|
||||
$("#L#{first_line}").ScrollTo()
|
||||
|
||||
# Highlight the correct lines on load
|
||||
highlightBlobLines()
|
||||
# Highlight the correct lines when the hash part of the URL changes
|
||||
$(window).on 'hashchange', highlightBlobLines
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue