File tree Expand file tree Collapse file tree
extensions/ql-vscode/src/queries-panel Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -48,18 +48,20 @@ export class QueryPackDiscovery extends FilePathDiscovery<QueryPack> {
4848 return undefined ;
4949 }
5050
51+ if ( packs . length === 1 ) {
52+ return packs [ 0 ] . language ;
53+ }
54+
55+ // If the first two packs are from a different directory, then the first one is the nearest
56+ if ( dirname ( packs [ 0 ] . path ) !== dirname ( packs [ 1 ] . path ) ) {
57+ return packs [ 0 ] . language ;
58+ }
59+
5160 // If the first two packs are from the same directory then look at the filenames
52- if (
53- packs . length >= 2 &&
54- dirname ( packs [ 0 ] . path ) === dirname ( packs [ 1 ] . path )
55- ) {
56- if ( basename ( packs [ 0 ] . path ) === FALLBACK_QLPACK_FILENAME ) {
57- return packs [ 0 ] . language ;
58- } else {
59- return packs [ 1 ] . language ;
60- }
61- } else {
61+ if ( basename ( packs [ 0 ] . path ) === FALLBACK_QLPACK_FILENAME ) {
6262 return packs [ 0 ] . language ;
63+ } else {
64+ return packs [ 1 ] . language ;
6365 }
6466 }
6567
You can’t perform that action at this time.
0 commit comments