Skip to content

Commit 2afb758

Browse files
committed
first line selection
1 parent a5514f2 commit 2afb758

3 files changed

Lines changed: 49 additions & 0 deletions

File tree

CHANGELOG.md

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

88
## [Unreleased]
99

10+
### Changed
11+
12+
- When first line is focused, without a selection, show the whole file on GitHub (#74)
13+
1014
## 3.4.0 - 2026-03-07
1115

1216
### Changed

src/providers.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ export class Github extends BaseProvider {
113113
PROVIDER_NAME = "github"
114114

115115
buildLines({ start, end }: ISelection): string {
116+
if (start.line === end.line && start.character === end.character) {
117+
return ""
118+
}
119+
116120
let line = `L${start.line + 1}`
117121
if (start.character !== 0) {
118122
line += `C${start.character + 1}`

src/test/suite/providers.test.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,47 @@ suite("Github", async () => {
150150
assert.deepEqual(result, expected)
151151
}
152152
})
153+
test("if we have no selection on the first line, don't select anything", async () => {
154+
for (let url of [
155+
"git@github.mycompany.com:recipeyak/recipeyak.git",
156+
"git@github.mycompany.com:recipeyak/recipeyak",
157+
"org-XYZ123@github.mycompany.com:recipeyak/recipeyak",
158+
"ssh://git@github.mycompany.com/recipeyak/recipeyak.git",
159+
]) {
160+
async function findRemote(hostname: string) {
161+
return url
162+
}
163+
const gh = new Github(
164+
{
165+
github: { hostnames: ["github.mycompany.com"] },
166+
},
167+
"origin",
168+
findRemote,
169+
)
170+
const result = await gh.getUrls({
171+
selection: {
172+
start: { line: 0, character: 0 },
173+
end: { line: 0, character: 0 },
174+
},
175+
head: createBranch("master"),
176+
relativeFilePath: "frontend/src/components/App.tsx",
177+
})
178+
const expected = {
179+
blobUrl:
180+
"https://github.mycompany.com/recipeyak/recipeyak/blob/master/frontend/src/components/App.tsx",
181+
blameUrl:
182+
"https://github.mycompany.com/recipeyak/recipeyak/blame/master/frontend/src/components/App.tsx",
183+
compareUrl:
184+
"https://github.mycompany.com/recipeyak/recipeyak/compare/master",
185+
historyUrl:
186+
"https://github.mycompany.com/recipeyak/recipeyak/commits/master/frontend/src/components/App.tsx",
187+
prUrl:
188+
"https://github.mycompany.com/recipeyak/recipeyak/pull/new/master",
189+
repoUrl: "https://github.mycompany.com/recipeyak/recipeyak",
190+
}
191+
assert.deepEqual(result, expected)
192+
}
193+
})
153194
})
154195

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

0 commit comments

Comments
 (0)