@@ -17,7 +17,7 @@ var findParentDir = require('find-parent-dir');
1717
1818const gitProvider = require ( './gitProvider' ) ;
1919
20- function getGitProviderLink ( cb , fileFsPath , line , pr ) {
20+ function getGitProviderLink ( cb , fileFsPath , lines , pr ) {
2121 var cwd = workspace . rootPath ;
2222 var repoDir = findParentDir . sync ( workspace . rootPath , '.git' ) || cwd ;
2323
@@ -48,9 +48,14 @@ function getGitProviderLink(cb, fileFsPath, line, pr) {
4848 cb ( provider . prUrl ( branch ) ) ;
4949 }
5050 else {
51- cb ( provider . webUrl ( branch , subdir , line ) ) ;
51+ if ( lines [ 0 ] == lines [ 1 ] ) {
52+ cb ( provider . webUrl ( branch , subdir , lines [ 0 ] ) ) ;
53+ }
54+ else {
55+ cb ( provider . webUrl ( branch , subdir , lines [ 0 ] , lines [ 1 ] ) ) ;
56+ }
5257 }
53-
58+
5459 } ) ;
5560 } ) ;
5661}
@@ -61,15 +66,21 @@ function getGitProviderLinkForFile(fileFsPath, cb) {
6166 getGitProviderLink ( cb , fileFsPath ) ;
6267}
6368
64- function getGitProviderLinkForCurrentEditorLine ( cb ) {
69+ function getGitProviderLinkForCurrentEditorLines ( cb ) {
6570 var editor = Window . activeTextEditor ;
6671 if ( editor ) {
67- var lineIndex = editor . selection . active . line + 1 ;
6872 var fileFsPath = editor . document . uri . fsPath ;
69- getGitProviderLink ( cb , fileFsPath , lineIndex ) ;
73+ getGitProviderLink ( cb , fileFsPath , getSelectedLines ( editor ) ) ;
7074 }
7175}
7276
77+ function getSelectedLines ( editor ) {
78+ var anchorLineIndex = editor . selection . anchor . line + 1 ;
79+ var activeLineIndex = editor . selection . active . line + 1 ;
80+
81+ return [ anchorLineIndex , activeLineIndex ] . sort ( ) ;
82+ }
83+
7384function getGitProviderLinkForRepo ( cb ) {
7485 getGitProviderLink ( cb ) ;
7586}
@@ -87,7 +98,7 @@ function branchOnCallingContext(args, cb, pr) {
8798 getGitProviderLinkForFile ( args . fsPath , cb ) ;
8899 }
89100 else if ( Window . activeTextEditor ) {
90- getGitProviderLinkForCurrentEditorLine ( cb ) ;
101+ getGitProviderLinkForCurrentEditorLines ( cb ) ;
91102 }
92103 else {
93104 getGitProviderLinkForRepo ( cb ) ;
0 commit comments