This repository was archived by the owner on Nov 15, 2017. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +12
-11
lines changed
Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -146,18 +146,19 @@ function gotoExtensionURL(url) {
146146 // to the right of the active tab
147147 chrome . tabs . query ( { active : true } , function ( tabs ) {
148148 var index = tabs . length ? tabs [ 0 ] . index : 9999 ;
149- chrome . tabs . query ( { url : url } , function ( tabs ) {
150- // Activate found matching tab
151- if ( tabs . length ) {
152- // Commented out as per:
153- // https://github.com/gorhill/httpswitchboard/issues/150#issuecomment-32683726
154- // chrome.tabs.move(tabs[0].id, { index: index + 1 });
155- chrome . tabs . update ( tabs [ 0 ] . id , { active : true } ) ;
156- }
157- // If it doesn't exist, create new tab
158- else {
159- chrome . tabs . create ( { 'url' : url , index : index + 1 } ) ;
149+ chrome . tabs . query ( { currentWindow : true } , function ( tabs ) {
150+ var i = tabs . length ;
151+ while ( i -- ) {
152+ if ( tabs [ i ] . url === url ) {
153+ // Activate found matching tab
154+ // Commented out as per:
155+ // https://github.com/gorhill/httpswitchboard/issues/150#issuecomment-32683726
156+ // chrome.tabs.move(tabs[0].id, { index: index + 1 });
157+ chrome . tabs . update ( tabs [ i ] . id , { active : true } ) ;
158+ return ;
159+ }
160160 }
161+ chrome . tabs . create ( { 'url' : url , index : index + 1 } ) ;
161162 } ) ;
162163 } ) ;
163164}
You can’t perform that action at this time.
0 commit comments