Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #450 from ueokande/fix-trim-start
Browse files Browse the repository at this point in the history
Fix trim start
  • Loading branch information
ueokande authored Aug 8, 2018
2 parents b48c2f7 + c1d927b commit ab85765
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
docker:
- image: circleci/node:10-stretch-browsers
environment:
- FIREFOX_VERSION: "60.0.2"
- FIREFOX_VERSION: "60.0esr"
working_directory: ~
steps:
- restore_cache:
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Vim Vixen",
"description": "Vim Vixen",
"version": "0.16",
"version": "0.17",
"icons": {
"48": "resources/icon_48x48.png",
"96": "resources/icon_96x96.png"
Expand Down
13 changes: 9 additions & 4 deletions src/background/controllers/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,25 @@ import CompletionsInteractor from '../usecases/completions';
import CommandInteractor from '../usecases/command';
import Completions from '../domains/completions';

const trimStart = (str) => {
// NOTE String.trimStart is available on Firefox 61
return str.replace(/^\s+/, '');
};

export default class CommandController {
constructor() {
this.completionsInteractor = new CompletionsInteractor();
this.commandIndicator = new CommandInteractor();
}

getCompletions(line) {
let trimmed = line.trimStart();
let trimmed = trimStart(line);
let words = trimmed.split(/ +/);
let name = words[0];
if (words.length === 1) {
return this.completionsInteractor.queryConsoleCommand(name);
}
let keywords = trimmed.slice(name.length).trimStart();
let keywords = trimStart(trimmed.slice(name.length));
switch (words[0]) {
case 'o':
case 'open':
Expand Down Expand Up @@ -45,14 +50,14 @@ export default class CommandController {

// eslint-disable-next-line complexity
exec(line) {
let trimmed = line.trimStart();
let trimmed = trimStart(line);
let words = trimmed.split(/ +/);
let name = words[0];
if (words[0].length === 0) {
return Promise.resolve();
}

let keywords = trimmed.slice(name.length).trimStart();
let keywords = trimStart(trimmed.slice(name.length));
switch (words[0]) {
case 'o':
case 'open':
Expand Down

0 comments on commit ab85765

Please sign in to comment.