From 6d7f44e091a47c28bbcf7c169ec3775b6fa7aac5 Mon Sep 17 00:00:00 2001 From: Amanda Cameron Date: Sat, 16 Sep 2017 17:33:05 -0400 Subject: [PATCH] Fix GitLab integration's multi-line selection. --- src/git/remotes/gitlab.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/git/remotes/gitlab.ts b/src/git/remotes/gitlab.ts index 60e99d0..76486e1 100644 --- a/src/git/remotes/gitlab.ts +++ b/src/git/remotes/gitlab.ts @@ -1,4 +1,5 @@ 'use strict'; +import { Range } from 'vscode'; import { GitHubService } from './github'; export class GitLabService extends GitHubService { @@ -10,4 +11,20 @@ export class GitLabService extends GitHubService { get name() { return this.formatName('GitLab'); } + + protected getUrlForFile(fileName: string, branch?: string, sha?: string, range?: Range): string { + let line = ''; + if (range) { + if (range.start.line === range.end.line) { + line = `#L${range.start.line}`; + } + else { + line = `#L${range.start.line}-${range.end.line}`; + } + } + + if (sha) return `${this.baseUrl}/blob/${sha}/${fileName}${line}`; + if (branch) return `${this.baseUrl}/blob/${branch}/${fileName}${line}`; + return `${this.baseUrl}?path=${fileName}${line}`; + } } \ No newline at end of file