mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
calculate prefix for path completion contributor properly
This commit is contained in:
+5
-3
@@ -101,8 +101,8 @@ public class FilePathCompletionContributor extends CompletionContributor {
|
||||
if (first == null) return;
|
||||
|
||||
final FileReferenceSet set = first.getFileReferenceSet();
|
||||
String prefix = set.getPathString().replace(CompletionUtil.DUMMY_IDENTIFIER_TRIMMED, "");
|
||||
|
||||
String prefix = set.getPathString().substring(0, parameters.getOffset() - set.getElement().getTextRange().getStartOffset() - set.getStartInElement());
|
||||
|
||||
final List<String>[] pathPrefixParts = new List[] {null};
|
||||
int lastSlashIndex;
|
||||
if ((lastSlashIndex = prefix.lastIndexOf('/')) != -1) {
|
||||
@@ -110,6 +110,8 @@ public class FilePathCompletionContributor extends CompletionContributor {
|
||||
prefix = prefix.substring(lastSlashIndex + 1);
|
||||
}
|
||||
|
||||
final CompletionResultSet __result = result.withPrefixMatcher(prefix).caseInsensitive();
|
||||
|
||||
final PsiFile originalFile = parameters.getOriginalFile();
|
||||
final VirtualFile contextFile = originalFile.getVirtualFile();
|
||||
if (contextFile != null) {
|
||||
@@ -147,7 +149,7 @@ public class FilePathCompletionContributor extends CompletionContributor {
|
||||
if (virtualFile != null && virtualFile.isValid() && virtualFile != contextFile) {
|
||||
if (contextHelper.isMine(project, virtualFile)) {
|
||||
if (pathPrefixParts[0] == null || fileMatchesPathPrefix(contextHelper.getPsiFileSystemItem(project, virtualFile), pathPrefixParts[0])) {
|
||||
result.addElement(new FilePathLookupItem(file, contextHelper));
|
||||
__result.addElement(new FilePathLookupItem(file, contextHelper));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user