Skip to content

Commit

Permalink
fix(completion): prevent calling disabled search engines
Browse files Browse the repository at this point in the history
  • Loading branch information
b-coimbra committed Jun 16, 2022
1 parent 95fdbc1 commit 821d1e6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# vimch

![v](https://img.shields.io/badge/version-0.0.4-green)
![v](https://img.shields.io/badge/version-0.0.41-green)

vimch - Vim Bindings for Chromium. This is a fork of [cVim](https://github.com/1995eaton/chromium-vim) (discontinued) and [vb4c](https://github.com/dcchambers/vb4c) (archived).

Expand Down
19 changes: 14 additions & 5 deletions content_scripts/complete.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,25 @@ var Complete = {
return '';

input[0] = this.getAlias(input[0]) || input[0];

const callDefaultEngine = (searchTerms) => {
const defaultEngine =
Complete.getEngine(settings.defaultengine) ??
Complete.getEngine('google');

return defaultEngine.requestUrl + encodeURIComponent(searchTerms.join(' '));
};

if (!this.engineEnabled(input[0]))
return callDefaultEngine(input);

if (!this.hasEngine(input[0])) {
if (!isLink && (isURL || Utils.isValidURL(input.join(' ')))) {
input = input.join(' ');
return (!/^[a-zA-Z\-]+:/.test(input) ? 'http://' : '') +
input;
}
var defaultEngine = this.getEngine(settings.defaultengine);
return (defaultEngine ? defaultEngine.requestUrl :
this.getEngine('google').requestUrl) +
encodeURIComponent(input.join(' '));
return callDefaultEngine(input);
}

var engine = this.getEngine(input[0]);
Expand Down Expand Up @@ -134,7 +143,7 @@ var Complete = {
this.activeEngines.push(name);
},
engineEnabled: function(name) {
return this.activeEngines.indexOf(name) !== -1;
return this.hasEngine(name) && this.activeEngines.indexOf(name) !== -1;
}
};

Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "vimch",
"version": "0.0.3",
"version": "0.0.41",
"description": "vimch: Vim Bindings For Chromium. A fork of cVim.",
"icons": {
"128": "icons/128.png",
Expand Down

0 comments on commit 821d1e6

Please sign in to comment.