Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use regex in find mode #376

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 17 additions & 2 deletions vimiumFrontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var getCurrentUrlHandlers = []; // function(url)

var insertModeLock = null;
var findMode = false;
var findModeMatchIndex = 0;
var findModeQuery = "";
var findModeQueryHasResults = false;
var isShowingHelpDialog = false;
Expand Down Expand Up @@ -599,8 +600,8 @@ function handleDeleteForFindMode() {
}

function handleEnterForFindMode() {
exitFindMode();
performFindInPlace();
exitFindMode();
}

function performFindInPlace() {
Expand All @@ -619,7 +620,21 @@ function performFindInPlace() {
}

function executeFind(backwards) {
findModeQueryHasResults = window.find(findModeQuery, false, backwards, true, false, true, false);
var pattern = new RegExp(findModeQuery, "g");
var text = document.body.textContent;
var result = text.match(pattern);
if ( ! findMode )
if (backwards)
if (findModeMatchIndex > 0)
findModeMatchIndex -= 1;
else
findModeMatchIndex = result.length - 1;
else
if (findModeMatchIndex < result.length - 1)
findModeMatchIndex += 1;
else
findModeMatchIndex = 0;
findModeQueryHasResults = window.find(result[findModeMatchIndex], false, backwards, true, false, true, false);
}

function focusFoundLink() {
Expand Down