Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Extension now calls `git` instead of manually reading `.git/` files. (#75)
- When there is no selection, link to the whole file on GitHub (#74)

## 3.4.0 - 2026-03-07

Expand Down
4 changes: 4 additions & 0 deletions src/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ export class Github extends BaseProvider {
PROVIDER_NAME = "github"

buildLines({ start, end }: ISelection): string {
if (start.line === end.line && start.character === end.character) {
return ""
}

let line = `L${start.line + 1}`
if (start.character !== 0) {
line += `C${start.character + 1}`
Expand Down
22 changes: 22 additions & 0 deletions src/test/suite/providers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,28 @@ suite("Github", async () => {
assert.deepEqual(result, expected)
}
})
test("if we have no selection on the first line, don't select anything", async () => {
const gh = new Github(
{
github: { hostnames: ["github.mycompany.com"] },
},
"origin",
async () => "git@github.mycompany.com:recipeyak/recipeyak.git",
)
const result = await gh.getUrls({
selection: {
start: { line: 0, character: 0 },
end: { line: 0, character: 0 },
},
head: createBranch("master"),
relativeFilePath: "frontend/src/components/App.tsx",
})

assert.deepEqual(
result?.blobUrl,
"https://github.mycompany.com/recipeyak/recipeyak/blob/master/frontend/src/components/App.tsx",
)
})
})

suite("Gitlab", async () => {
Expand Down