mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
goto file: restore understanding of queries with wrong (russian) keyboard layout
This commit is contained in:
@@ -22,6 +22,7 @@ import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.application.ModalityState
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.psi.CommonClassNames
|
||||
import com.intellij.psi.PsiClass
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.psi.search.ProjectScope
|
||||
@@ -154,12 +155,12 @@ class Intf {
|
||||
assert elements == files
|
||||
}
|
||||
|
||||
void "test middle matching for directories"() {
|
||||
void "test middle matching for files and directories"() {
|
||||
def fooIndex = myFixture.addFileToProject("foo/index.html", "foo")
|
||||
def ooIndex = myFixture.addFileToProject("oo/index.html", "oo")
|
||||
def fooBarIndex = myFixture.addFileToProject("foo/bar/index.html", "foo bar")
|
||||
def elements = getPopupElements(new GotoFileModel(project), "oo/index")
|
||||
assert elements == [ooIndex, fooIndex, fooBarIndex]
|
||||
assert getPopupElements(new GotoFileModel(project), "oo/index") == [ooIndex, fooIndex, fooBarIndex]
|
||||
assert getPopupElements(new GotoFileModel(project), "ndex.html") == [fooIndex, ooIndex, fooBarIndex]
|
||||
}
|
||||
|
||||
void "test prefer files from current directory"() {
|
||||
@@ -394,6 +395,12 @@ class Intf {
|
||||
assert calcPopupElements(popup, "somefb\\index.html") == [someFbFile]
|
||||
}
|
||||
|
||||
void "test fix keyboard layout"() {
|
||||
assert (getPopupElements(new GotoClassModel2(project), 'Ыекштп')[0] as PsiClass).name == 'String'
|
||||
assert (getPopupElements(new GotoSymbolModel2(project), 'Ыекштп')[0] as PsiClass).name == 'String'
|
||||
assert (getPopupElements(new GotoFileModel(project), 'Ыекштп')[0] as PsiFile).name == 'String.class'
|
||||
}
|
||||
|
||||
void "test prefer exact case match"() {
|
||||
def upper = myFixture.addClass("class SOMECLASS {}")
|
||||
def camel = myFixture.addClass("class SomeClass {}")
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFileSystemItem;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.codeStyle.FixingLayoutMatcher;
|
||||
import com.intellij.psi.codeStyle.MinusculeMatcher;
|
||||
import com.intellij.psi.codeStyle.NameUtil;
|
||||
import com.intellij.util.Processor;
|
||||
@@ -162,6 +163,7 @@ public class GotoFileItemProvider extends DefaultChooseByNameItemProvider {
|
||||
|
||||
private class NameGrouper {
|
||||
private final String namePattern;
|
||||
@Nullable private final String alternativePattern;
|
||||
|
||||
/** Names placed into buckets where the index of bucket == {@link #findMatchStartingPosition} */
|
||||
private final List<List<String>> candidateNames;
|
||||
@@ -170,12 +172,16 @@ public class GotoFileItemProvider extends DefaultChooseByNameItemProvider {
|
||||
|
||||
NameGrouper(@NotNull String namePattern) {
|
||||
this.namePattern = namePattern;
|
||||
alternativePattern = FixingLayoutMatcher.fixLayout(namePattern);
|
||||
candidateNames = IntStreamEx.range(0, namePattern.length()).mapToObj(__ -> (List<String>)new ArrayList<String>()).toList();
|
||||
}
|
||||
|
||||
boolean processName(String name) {
|
||||
ProgressManager.checkCanceled();
|
||||
int position = findMatchStartingPosition(name, namePattern);
|
||||
if (position >= namePattern.length() && alternativePattern != null) {
|
||||
position = findMatchStartingPosition(name, alternativePattern);
|
||||
}
|
||||
if (position < namePattern.length()) {
|
||||
List<String> list = candidateNames.get(position);
|
||||
//noinspection SynchronizationOnLocalVariableOrMethodParameter
|
||||
|
||||
Reference in New Issue
Block a user