mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-08-11 00:40:37 +02:00
integrating findNext and findPrevious
This commit is contained in:
parent
6c24ddd1a0
commit
9859974db7
src/main/java/com/maddyhome/idea/vim/helper
vim-engine/src/main/kotlin/com/maddyhome/idea/vim/regexp
@ -23,6 +23,8 @@ import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.api.EngineEditorHelperKt;
|
||||
import com.maddyhome.idea.vim.api.VimEditor;
|
||||
import com.maddyhome.idea.vim.regexp.VimRegex;
|
||||
import com.maddyhome.idea.vim.regexp.match.VimMatchResult;
|
||||
import com.maddyhome.idea.vim.state.mode.Mode;
|
||||
import com.maddyhome.idea.vim.state.VimStateMachine;
|
||||
import com.maddyhome.idea.vim.common.CharacterPosition;
|
||||
@ -74,13 +76,25 @@ public class SearchHelper {
|
||||
int startOffset,
|
||||
int count,
|
||||
EnumSet<SearchOptions> searchOptions) {
|
||||
if (pattern == null || pattern.length() == 0) {
|
||||
if (pattern == null || pattern.isEmpty()) {
|
||||
logger.warn("Pattern is null or empty. Cannot perform search");
|
||||
return null;
|
||||
}
|
||||
|
||||
Direction dir = searchOptions.contains(SearchOptions.BACKWARDS) ? Direction.BACKWARDS : Direction.FORWARDS;
|
||||
|
||||
// TODO: we don't have access to globalijoptions here, since this is a java file!
|
||||
boolean useNewRegex = false;
|
||||
if (useNewRegex) {
|
||||
final VimRegex regex = new VimRegex(pattern);
|
||||
final VimEditor vimEditor = new IjVimEditor(editor);
|
||||
VimMatchResult result;
|
||||
if (dir == Direction.FORWARDS) result = regex.findNext(vimEditor, startOffset);
|
||||
else result = regex.findPrevious(vimEditor, startOffset);
|
||||
if (result.getClass() == VimMatchResult.Success.class) return ((VimMatchResult.Success)result).getRange();
|
||||
else return null;
|
||||
}
|
||||
|
||||
//RE sp;
|
||||
RegExp sp;
|
||||
RegExp.regmmatch_T regmatch = new RegExp.regmmatch_T();
|
||||
|
@ -116,7 +116,7 @@ public class VimRegex(pattern: String) {
|
||||
}
|
||||
index = 0
|
||||
// no match found after startIndex, try wrapping around to file start
|
||||
while (index < lineStartIndex) {
|
||||
while (index <= startIndex) {
|
||||
val result = simulateNFA(editor, index)
|
||||
// just return the first match found
|
||||
when (result) {
|
||||
|
Loading…
Reference in New Issue
Block a user