Support markdown anchors and multi-line in permalink
What does this MR do and why?
AI Summary
This change improves how line numbers and URL hashes are handled in the code viewer. The main improvements are:
- The code now properly synchronizes the URL hash (the part after # in the URL) with the application state when users navigate to specific lines of code.
- A new utility function
getAbsolutePermalinkPathwas created to consistently generate permalink URLs that include the correct line numbers or section anchors. - The code now properly handles different hash formats (like line numbers "L42", line ranges "L10-19", and section anchors like "#section-heading").
- Event listeners were added to detect when the URL hash changes, ensuring the application state stays in sync with the browser's URL.
- Removed redundant click handling code that was updating line numbers, as this is now handled more consistently through the hash change mechanism.
References
Resolves #537733 (closed) #521756 (closed)
Screenshots or screen recordings
How to set up and validate locally
- Go to a file/Open a file link
- Select line/multi-lines/markdown anchor
- Select permalink from overflow menu or press
y
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by Chaoyue Zhao