Skip to content

Commit

Permalink
Debugger: no camelhump matching in variables view (WI-43358)
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Shatrov authored and Viktor Shatrov committed Sep 3, 2018
1 parent 95f7ffa commit 960bff5
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,42 @@
*/
package com.intellij.xdebugger.impl.ui.tree;

import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.LoadingNode;
import com.intellij.ui.SpeedSearchComparator;
import com.intellij.ui.TreeSpeedSearch;
import com.intellij.util.ObjectUtils;
import com.intellij.util.containers.Convertor;
import com.intellij.util.ui.tree.TreeUtil;
import com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.tree.TreePath;
import java.util.Collections;

class XDebuggerTreeSpeedSearch extends TreeSpeedSearch {

public final int SEARCH_DEPTH = Registry.intValue("debugger.variablesView.rss.depth");

public XDebuggerTreeSpeedSearch(XDebuggerTree tree, Convertor<TreePath, String> toStringConvertor) {
public XDebuggerTreeSpeedSearch(XDebuggerTree tree, Convertor<? super TreePath, String> toStringConvertor) {
super(tree, toStringConvertor, true);
setComparator(new SpeedSearchComparator(false, false) {

@Override
public int matchingDegree(String pattern, String text) {
return matchingFragments(pattern, text) != null ? 1 : 0;
}

@Nullable
@Override
public Iterable<TextRange> matchingFragments(@NotNull String pattern, @NotNull String text) {
int index = StringUtil.indexOfIgnoreCase(text, pattern, 0);
return index >= 0 ? Collections.singleton(TextRange.from(index, pattern.length())) : null;
}
});
}

@NotNull
Expand Down

0 comments on commit 960bff5

Please sign in to comment.