mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
tests: navigate to correct offset in plain text files (IDEA-198881)
This commit is contained in:
@@ -19,6 +19,7 @@ import com.intellij.execution.Location;
|
||||
import com.intellij.execution.PsiLocation;
|
||||
import com.intellij.execution.testframework.sm.runner.SMTestLocator;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
@@ -131,6 +132,18 @@ public class FileUrlProvider implements SMTestLocator, DumbAware {
|
||||
int length = elementAtLine.getTextLength();
|
||||
offset += length > 1 ? length - 1 : 1;
|
||||
}
|
||||
|
||||
if (elementAtLine instanceof PsiPlainText && offset > 0) {
|
||||
int offsetInPlainTextFile = offset;
|
||||
return new PsiLocation<PsiPlainText>(project, (PsiPlainText)elementAtLine) {
|
||||
@Nullable
|
||||
@Override
|
||||
public OpenFileDescriptor getOpenFileDescriptor() {
|
||||
VirtualFile file = getVirtualFile();
|
||||
return file != null ? new OpenFileDescriptor(getProject(), file, offsetInPlainTextFile) : null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return PsiLocation.fromPsiElement(project, elementAtLine != null ? elementAtLine : psiFile);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user