From 3be04a44914ff495c3553aca363b08bebe7529c3 Mon Sep 17 00:00:00 2001 From: Christopher Dignam Date: Wed, 5 Nov 2025 20:09:26 -0500 Subject: [PATCH 1/3] Only add column offsets when they are non-zero for GitHub. --- CHANGELOG.md | 6 ++++++ package.json | 2 +- src/providers.ts | 18 +++++++++++++----- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f298a0..19fe4a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. + ## 3.2.2 - 2025-07-02 ### Fixed diff --git a/package.json b/package.json index 7783d95..350d4a1 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/providers.ts b/src/providers.ts index 16f84fe..7db2c18 100644 --- a/src/providers.ts +++ b/src/providers.ts @@ -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, @@ -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, From 452359833231510cdf3ff62c45ffead8fba2a9c1 Mon Sep 17 00:00:00 2001 From: Christopher Dignam Date: Wed, 5 Nov 2025 20:10:34 -0500 Subject: [PATCH 2/3] . --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19fe4a1..c4b0317 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- Only add column offsets when they are non-zero for GitHub. +- Only add column offsets when they are non-zero for GitHub. (#68) ## 3.2.2 - 2025-07-02 From e997234ebbcee0a7ae1d0938655aeee35dcf57a8 Mon Sep 17 00:00:00 2001 From: Christopher Dignam Date: Wed, 5 Nov 2025 20:14:12 -0500 Subject: [PATCH 3/3] fix test --- src/test/suite/providers.test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/suite/providers.test.ts b/src/test/suite/providers.test.ts index b06dcce..d3e390a 100644 --- a/src/test/suite/providers.test.ts +++ b/src/test/suite/providers.test.ts @@ -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: @@ -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: