Skip to content

Commit 34cb919

Browse files
authored
clamp last line to first line (#70)
Fixes #69
1 parent 4c4efc0 commit 34cb919

4 files changed

Lines changed: 52 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## 3.4.0 - 2026-03-07
11+
12+
### Changed
13+
14+
- Only add column offset for last line when first line's column is non-zero for GitHub. (#70)
15+
1016
## 3.3.0 - 2025-11-05
1117

1218
### Changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "githubinator",
33
"displayName": "Githubinator",
44
"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.",
5-
"version": "3.3.0",
5+
"version": "3.4.0",
66
"publisher": "chdsbd",
77
"license": "SEE LICENSE IN LICENSE",
88
"icon": "images/logo256.png",
@@ -471,6 +471,7 @@
471471
"lodash": "^4.17.21",
472472
"mz": "^2.7.0"
473473
},
474+
"packageManager": "yarn@1.22.22",
474475
"volta": {
475476
"node": "18.20.3",
476477
"yarn": "1.22.22"

src/providers.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ export class Github extends BaseProvider {
116116
let line = `L${start.line + 1}`
117117
if (start.character !== 0) {
118118
line += `C${start.character + 1}`
119+
} else {
120+
line += `-L${end.line + 1}`
121+
return line
119122
}
120123
line += `-L${end.line + 1}`
121124
if (end.character !== 0) {

src/test/suite/providers.test.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,47 @@ suite("Github", async () => {
109109
assert.deepEqual(result, expected)
110110
}
111111
})
112+
test("if column of first line is 0, last line should be 0", async () => {
113+
for (let url of [
114+
"git@github.mycompany.com:recipeyak/recipeyak.git",
115+
"git@github.mycompany.com:recipeyak/recipeyak",
116+
"org-XYZ123@github.mycompany.com:recipeyak/recipeyak",
117+
"ssh://git@github.mycompany.com/recipeyak/recipeyak.git",
118+
]) {
119+
async function findRemote(hostname: string) {
120+
return url
121+
}
122+
const gh = new Github(
123+
{
124+
github: { hostnames: ["github.mycompany.com"] },
125+
},
126+
"origin",
127+
findRemote,
128+
)
129+
const result = await gh.getUrls({
130+
selection: {
131+
start: { line: 17, character: 0 },
132+
end: { line: 24, character: 5 },
133+
},
134+
head: createBranch("master"),
135+
relativeFilePath: "frontend/src/components/App.tsx",
136+
})
137+
const expected = {
138+
blobUrl:
139+
"https://github.mycompany.com/recipeyak/recipeyak/blob/master/frontend/src/components/App.tsx#L18-L25",
140+
blameUrl:
141+
"https://github.mycompany.com/recipeyak/recipeyak/blame/master/frontend/src/components/App.tsx#L18-L25",
142+
compareUrl:
143+
"https://github.mycompany.com/recipeyak/recipeyak/compare/master",
144+
historyUrl:
145+
"https://github.mycompany.com/recipeyak/recipeyak/commits/master/frontend/src/components/App.tsx",
146+
prUrl:
147+
"https://github.mycompany.com/recipeyak/recipeyak/pull/new/master",
148+
repoUrl: "https://github.mycompany.com/recipeyak/recipeyak",
149+
}
150+
assert.deepEqual(result, expected)
151+
}
152+
})
112153
})
113154

114155
suite("Gitlab", async () => {

0 commit comments

Comments
 (0)