Skip to content

Commit ac6be78

Browse files
committed
Manual completion option
Command completions (e.g. for 'open' commands) were previously automatically updated when command characters are being typed. This commit adds a boolean option 'manualcompletion' that makes the completions update only when Tab key is pressed. Resolves #379.
1 parent 328e37d commit ac6be78

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ These extensions do a wonderful job of adding Vim-like keybindings to Google Chr
6363
| sortlinkhints | boolean | Sort link hint lettering by the link's distance from the top-left corner of the page | false |
6464
| localconfig | boolean | Read the cVimrc config from `configpath` (when this is set, you connot save from cVim's options page | false |
6565
| completeonopen | boolean | Automatically show a list of command completions when the command bar is opened | false |
66+
| manualcompletion | boolean | Wait for Tab key instead of automatically showing command completions (e.g. with 'open') | false |
6667
| configpath | string | Read the cVimrc from this local file when configpath is set | "" |
6768
| changelog | boolean | Auto open the changelog when cVim is updated | true |
6869
| completionengines | array of strings | use only the specified search engines | ["google", "duckduckgo", "wikipedia", "amazon"] |

background_scripts/options.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ var defaultSettings = {
5555
changelog: true,
5656
localconfig: false,
5757
completeonopen: false,
58+
manualcompletion: false,
5859
scrollduration: 500,
5960
zoomfactor: 0.10,
6061
configpath: '',

content_scripts/command.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Command.dataElements = [];
4545
Command.matches = [];
4646
Command.customCommands = {};
4747
Command.lastInputValue = '';
48+
Command.completionsNeedUpdate = false;
4849

4950
Command.setupFrameElements = function() {
5051
this.bar = document.createElement('div');
@@ -181,8 +182,17 @@ Command.completionOrder = {
181182
};
182183

183184
Command.updateCompletions = function(useStyles) {
185+
if (settings.manualcompletion) {
186+
this.completionsNeedUpdate = true;
187+
} else {
188+
this.executeCompletionUpdate(useStyles);
189+
}
190+
};
191+
192+
Command.executeCompletionUpdate = function(useStyles) {
184193
if (!window.isCommandFrame)
185194
return;
195+
this.completionsNeedUpdate = false;
186196
this.completionResults = [];
187197
this.dataElements = [];
188198
this.data.innerHTML = '';

content_scripts/keys.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,12 @@ var KeyHandler = {
387387
case '<S-Tab>':
388388
if (Command.type === 'action') {
389389
event.preventDefault();
390-
Mappings.actions[ (key === '<Tab>' ? 'next' : 'previous') +
391-
'CompletionResult' ]();
390+
if (Command.completionsNeedUpdate) {
391+
Command.executeCompletionUpdate(true);
392+
} else {
393+
Mappings.actions[ (key === '<Tab>' ? 'next' : 'previous') +
394+
'CompletionResult' ]();
395+
}
392396
}
393397
break;
394398
case '<C-p>':

pages/mappings.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,12 @@ <h3 id="cvimrc">cVimrc</h3>
241241
<td style="text-align:right">false</td>
242242
</tr>
243243
<tr>
244+
<td>manualcompletion</td>
245+
<td>boolean</td>
246+
<td>Wait for Tab key instead of automatically showing command completions (e.g. with 'open')</td>
247+
<td style="text-align:right">false</td>
248+
</tr>
249+
<tr>
244250
<td>configpath</td>
245251
<td>string</td>
246252
<td>Read the cVimrc from this local file when configpath is set</td>
@@ -1406,4 +1412,4 @@ <h1 id="contributing">Contributing</h1>
14061412
<li>Click on &quot;Load Unpacked Extension...&quot;</li>
14071413
<li>Select the cVim directory.</li>
14081414
</ol>
1409-
</html>
1415+
</html>

0 commit comments

Comments
 (0)