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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## 3.3.0 - 2025-11-05

### Changed

- Only add column offsets when they are non-zero for GitHub. (#68)

## 3.2.2 - 2025-07-02

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "githubinator",
"displayName": "Githubinator",
"description": "Quickly open files on Github and other providers. View blame information, copy permalinks and more. See the \"commands\" section of the README for more details.",
"version": "3.2.2",
"version": "3.3.0",
"publisher": "chdsbd",
"license": "SEE LICENSE IN LICENSE",
"icon": "images/logo256.png",
Expand Down
18 changes: 13 additions & 5 deletions src/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,18 @@ export function pathJoin(...args: string[]): string {
export class Github extends BaseProvider {
DEFAULT_HOSTNAMES = ["github.com"]
PROVIDER_NAME = "github"

buildLines({ start, end }: ISelection): string {
let line = `L${start.line + 1}`
if (start.character !== 0) {
line += `C${start.character + 1}`
}
line += `-L${end.line + 1}`
if (end.character !== 0) {
line += `C${end.character + 1}`
}
return line
}
async getUrls({
selection,
head,
Expand All @@ -121,11 +133,7 @@ export class Github extends BaseProvider {
return null
}
const rootUrl = `https://${repoInfo.hostname}/`
const { start, end } = selection
// Github uses 1-based indexing
const lines = `L${start.line + 1}C${start.character + 1}-L${
end.line + 1
}C${end.character + 1}`
const lines = this.buildLines(selection)
const repoUrl = new url.URL(
path.join(repoInfo.org, repoInfo.repo),
rootUrl,
Expand Down
12 changes: 6 additions & 6 deletions src/test/suite/providers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ suite("Github", async () => {
})
const expected = {
blobUrl:
"https://github.com/recipeyak/recipeyak/blob/db99a912f5c4bffe11d91e163cd78ed96589611b/frontend/src/components/App.tsx#L18C1-L25C1",
"https://github.com/recipeyak/recipeyak/blob/db99a912f5c4bffe11d91e163cd78ed96589611b/frontend/src/components/App.tsx#L18-L25",
blameUrl:
"https://github.com/recipeyak/recipeyak/blame/db99a912f5c4bffe11d91e163cd78ed96589611b/frontend/src/components/App.tsx#L18C1-L25C1",
"https://github.com/recipeyak/recipeyak/blame/db99a912f5c4bffe11d91e163cd78ed96589611b/frontend/src/components/App.tsx#L18-L25",
compareUrl:
"https://github.com/recipeyak/recipeyak/compare/db99a912f5c4bffe11d91e163cd78ed96589611b",
historyUrl:
Expand Down Expand Up @@ -87,17 +87,17 @@ suite("Github", async () => {
)
const result = await gh.getUrls({
selection: {
start: { line: 17, character: 0 },
end: { line: 24, character: 0 },
start: { line: 17, character: 4 },
end: { line: 24, character: 5 },
},
head: createBranch("master"),
relativeFilePath: "frontend/src/components/App.tsx",
})
const expected = {
blobUrl:
"https://github.mycompany.com/recipeyak/recipeyak/blob/master/frontend/src/components/App.tsx#L18C1-L25C1",
"https://github.mycompany.com/recipeyak/recipeyak/blob/master/frontend/src/components/App.tsx#L18C5-L25C6",
blameUrl:
"https://github.mycompany.com/recipeyak/recipeyak/blame/master/frontend/src/components/App.tsx#L18C1-L25C1",
"https://github.mycompany.com/recipeyak/recipeyak/blame/master/frontend/src/components/App.tsx#L18C5-L25C6",
compareUrl:
"https://github.mycompany.com/recipeyak/recipeyak/compare/master",
historyUrl:
Expand Down