dotnet / dotnet/docfx

[Bug] "View source" links to Azure DevOps do not highlight line in source code

Open
#10,447 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.4k
Forks
890
Avg merge
2h 9m
Merged PRs (30d)
11

Description

**Describe the bug**
When clicking a "View source" link to an Azure DevOps remote repository, there is no line highlighting in the Azure DevOps source code viewer.

The links currently append `&line={source.Line}` to the URL which does not achieve anything in the Azure DevOps source code viewer. To highlight a line of code, Azure DevOps requires:

```
&line={source.Line}&lineEnd={source.Line+1}&lineStartColumn=1&lineEndColumn=1&lineStyle=plain
```

This is the pattern generated when copying the link to a line within Azure DevOps and [is also described here.](https://developercommunity.visualstudio.com/t/add-support-for-link-to-a-file-with-line-number/1408473#T-N10178976) Result with `source.Line = 7`:

![Image](https://github.com/user-attachments/assets/7e75af85-da06-4445-b27d-4299c3493390)

The link seems to be generated here: https://github.com/dotnet/docfx/blob/main/src/Docfx.Common/Git/GitUtility.cs#L77

**To Reproduce**

1. Set up a DocFX project linked to an Azure DevOps remote repo.
2. Build the project and click "View source" on a member in the API documentation.
3. No lines are highlighted.

**Expected behavior**
I expect `startLine` in the API YAML file to be highlighted within Azure DevOps.

**Context (please complete the following information):**
- OS: Windows 10
- Docfx version: 2.78.2

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.