diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-06-17 12:05:05 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-17 12:05:05 +0900 |
commit | 7cae7302bd39a7963b765cd3defd05a093c104a6 (patch) | |
tree | b0c141f40007207c0fa87aefe9ebd28b4633ad10 /src | |
parent | cf7d482446727cd7b8a9a0bf2cd3038cc85fb225 (diff) | |
parent | 45a65b38db55e358d58e9c608a8088d7cc157939 (diff) |
Merge pull request #415 from ueokande/pattern-not-found-null
Fix no previous search keywords
Diffstat (limited to 'src')
-rw-r--r-- | src/content/actions/find.js | 9 | ||||
-rw-r--r-- | src/content/components/top-content/find.js | 13 |
2 files changed, 9 insertions, 13 deletions
diff --git a/src/content/actions/find.js b/src/content/actions/find.js index c7345cc..249a8a9 100644 --- a/src/content/actions/find.js +++ b/src/content/actions/find.js @@ -22,6 +22,12 @@ const postPatternFound = (pattern) => { ); }; +const postNoPrevious = () => { + return consoleFrames.postError( + window.document, + 'No previous search keywords'); +}; + const find = (string, backwards) => { let caseSensitive = false; let wrapScan = true; @@ -50,6 +56,9 @@ const findNext = (currentKeyword, reset, backwards) => { } return promise.then((keyword) => { + if (!keyword) { + return postNoPrevious(); + } let found = find(keyword, backwards); if (!found) { window.getSelection().removeAllRanges(); diff --git a/src/content/components/top-content/find.js b/src/content/components/top-content/find.js index c765292..4d46d79 100644 --- a/src/content/components/top-content/find.js +++ b/src/content/components/top-content/find.js @@ -1,6 +1,5 @@ import * as findActions from 'content/actions/find'; import messages from 'shared/messages'; -import * as consoleFrames from '../../console-frames'; export default class FindComponent { constructor(win, store) { @@ -32,23 +31,11 @@ export default class FindComponent { next() { let state = this.store.getState().find; - if (!state.keyword) { - return this.postNoPrevious(); - } return this.store.dispatch(findActions.next(state.keyword, false)); } prev() { let state = this.store.getState().find; - if (!state.keyword) { - return this.postNoPrevious(); - } return this.store.dispatch(findActions.prev(state.keyword, false)); } - - postNoPrevious() { - return consoleFrames.postError( - window.document, - 'No previous search keypards'); - } } |