Skip to content

Commit

Permalink
Use exact in dash trigger command
Browse files Browse the repository at this point in the history
use exact to prevent dash search in unspecified docsets based on
extension setting

closes #33
  • Loading branch information
deerawan committed Oct 22, 2018
1 parent aac26bf commit 8bae991
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
],
"main": "./out/src/extension",
"contributes": {
"commands": [{
"commands": [
{
"command": "extension.dash.specific",
"title": "Search in Dash for current selection"
},
Expand All @@ -49,7 +50,8 @@
"title": "Search in Dash for a custom string"
}
],
"keybindings": [{
"keybindings": [
{
"command": "extension.dash.specific",
"key": "ctrl+h",
"mac": "ctrl+h",
Expand Down
6 changes: 5 additions & 1 deletion src/dash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 '';
Expand Down
8 changes: 4 additions & 4 deletions test/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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'
);
});

Expand All @@ -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', () => {
Expand All @@ -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', () => {
Expand Down

0 comments on commit 8bae991

Please sign in to comment.