diff --git a/CHANGELOG.md b/CHANGELOG.md index c4b0317..6bfff59 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.4.0 - 2026-03-07 + +### Changed + +- Only add column offset for last line when first line's column is non-zero for GitHub. (#70) + ## 3.3.0 - 2025-11-05 ### Changed diff --git a/package.json b/package.json index 350d4a1..d25742a 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.3.0", + "version": "3.4.0", "publisher": "chdsbd", "license": "SEE LICENSE IN LICENSE", "icon": "images/logo256.png", @@ -471,6 +471,7 @@ "lodash": "^4.17.21", "mz": "^2.7.0" }, + "packageManager": "yarn@1.22.22", "volta": { "node": "18.20.3", "yarn": "1.22.22" diff --git a/src/providers.ts b/src/providers.ts index 7db2c18..8321b21 100644 --- a/src/providers.ts +++ b/src/providers.ts @@ -116,6 +116,9 @@ export class Github extends BaseProvider { let line = `L${start.line + 1}` if (start.character !== 0) { line += `C${start.character + 1}` + } else { + line += `-L${end.line + 1}` + return line } line += `-L${end.line + 1}` if (end.character !== 0) { diff --git a/src/test/suite/providers.test.ts b/src/test/suite/providers.test.ts index d3e390a..8531687 100644 --- a/src/test/suite/providers.test.ts +++ b/src/test/suite/providers.test.ts @@ -109,6 +109,47 @@ suite("Github", async () => { assert.deepEqual(result, expected) } }) + test("if column of first line is 0, last line should be 0", async () => { + for (let url of [ + "git@github.mycompany.com:recipeyak/recipeyak.git", + "git@github.mycompany.com:recipeyak/recipeyak", + "org-XYZ123@github.mycompany.com:recipeyak/recipeyak", + "ssh://git@github.mycompany.com/recipeyak/recipeyak.git", + ]) { + async function findRemote(hostname: string) { + return url + } + const gh = new Github( + { + github: { hostnames: ["github.mycompany.com"] }, + }, + "origin", + findRemote, + ) + const result = await gh.getUrls({ + selection: { + start: { line: 17, character: 0 }, + 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#L18-L25", + blameUrl: + "https://github.mycompany.com/recipeyak/recipeyak/blame/master/frontend/src/components/App.tsx#L18-L25", + compareUrl: + "https://github.mycompany.com/recipeyak/recipeyak/compare/master", + historyUrl: + "https://github.mycompany.com/recipeyak/recipeyak/commits/master/frontend/src/components/App.tsx", + prUrl: + "https://github.mycompany.com/recipeyak/recipeyak/pull/new/master", + repoUrl: "https://github.mycompany.com/recipeyak/recipeyak", + } + assert.deepEqual(result, expected) + } + }) }) suite("Gitlab", async () => {