diff --git a/package-lock.json b/package-lock.json index edc853f..13d969b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3947,15 +3947,6 @@ "integrity": "sha1-Rb8dny19wJvtgfHDB8Qw5ouEz/4=", "dev": true }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, "string-width": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", @@ -3967,6 +3958,15 @@ "strip-ansi": "3.0.1" } }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, "stringify-object": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/stringify-object/-/stringify-object-3.2.1.tgz", diff --git a/package.json b/package.json index 33180e1..d93d6a5 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,8 @@ ], "main": "./out/src/extension", "contributes": { - "commands": [{ + "commands": [ + { "command": "extension.dash.specific", "title": "Search in Dash for current selection" }, @@ -49,7 +50,8 @@ "title": "Search in Dash for a custom string" } ], - "keybindings": [{ + "keybindings": [ + { "command": "extension.dash.specific", "key": "ctrl+h", "mac": "ctrl+h", diff --git a/src/dash.ts b/src/dash.ts index 4f193a6..2ac5f44 100644 --- a/src/dash.ts +++ b/src/dash.ts @@ -40,7 +40,11 @@ export class Dash { */ getKeys(docsets: string[]): string { if (docsets.length > 0) { - return docsets.join(','); + // Dash has behaviour to search another docsets that have similarity with targeted docsets + // e.g search to typescript, will also search in vue + // Using exact to prevent that so it will search only in targeted docsets + const exactDocsets = docsets.map(docset => `exact:${docset}`); + return exactDocsets.join(','); } return ''; diff --git a/test/extension.test.ts b/test/extension.test.ts index 938becc..4e078ec 100644 --- a/test/extension.test.ts +++ b/test/extension.test.ts @@ -6,7 +6,7 @@ suite('Dash Tests', () => { const dash = new Dash('darwin'); const uri = dash.getCommand('size', ['css', 'less']); - assert.equal(uri, 'open -g "dash-plugin://query=size&keys=css,less"'); + assert.equal(uri, 'open -g "dash-plugin://query=size&keys=exact:css,exact:less"'); }); test('Get command with no keys for macOS', () => { @@ -22,7 +22,7 @@ suite('Dash Tests', () => { assert.equal( uri, - 'start dash-plugin:// && start dash-plugin://query=size^&keys=css,less' + 'start dash-plugin:// && start dash-plugin://query=size^&keys=exact:css,exact:less' ); }); @@ -37,7 +37,7 @@ suite('Dash Tests', () => { const dash = new Dash('linux'); const uri = dash.getCommand('size', ['css', 'less']); - assert.equal(uri, 'zeal "dash-plugin://query=size&keys=css,less"'); + assert.equal(uri, 'zeal "dash-plugin://query=size&keys=exact:css,exact:less"'); }); test('Get command with no keys for Linux', () => { @@ -51,7 +51,7 @@ suite('Dash Tests', () => { const dash = new Dash('darwin'); const keys = dash.getKeys(['css', 'less']); - assert.equal(keys, 'css,less'); + assert.equal(keys, 'exact:css,exact:less'); }); test('Get keys with empty docset', () => {