mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix whole-file smart range pointers on unicode files
This commit is contained in:
+9
@@ -1034,4 +1034,13 @@ public class SmartPsiElementPointersTest extends CodeInsightTestCase {
|
||||
assertEquals(TextRange.from(3, 1), TextRange.create(pointer.getRange()));
|
||||
}
|
||||
|
||||
public void testFileRangeWithUnicode() throws Exception {
|
||||
PsiFile file = createFile("a.java", "Ы");
|
||||
assertEquals(1, file.getTextLength());
|
||||
SmartPsiFileRange pointer = getPointerManager().createSmartPsiFileRangePointer(file, TextRange.from(0, file.getTextLength()));
|
||||
assertEquals(TextRange.from(0, 1), TextRange.create(pointer.getPsiRange()));
|
||||
assertEquals(TextRange.from(0, 1), TextRange.create(pointer.getRange()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -73,7 +73,10 @@ class FileElementInfo extends SmartPointerElementInfo {
|
||||
|
||||
@Override
|
||||
public Segment getRange() {
|
||||
return myVirtualFile.isValid() ? new TextRange(0, (int)myVirtualFile.getLength()) : null;
|
||||
if (!myVirtualFile.isValid()) return null;
|
||||
|
||||
Document document = FileDocumentManager.getInstance().getDocument(myVirtualFile);
|
||||
return document == null ? null : TextRange.from(0, document.getTextLength());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user