Skip to content

Commit

Permalink
#2894 final fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hurricup committed Sep 15, 2024
1 parent 29f0e1f commit c9257b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public boolean isOneLine() {
@Override
public boolean decode(@NotNull TextRange rangeInsideHost, @NotNull StringBuilder outChars) {
var hostTextLength = myHost.getTextLength();
var effectiveRange = hostTextLength < rangeInsideHost.getEndOffset() ?
var effectiveRange = rangeInsideHost.getEndOffset() < hostTextLength ?
rangeInsideHost :
TextRange.create(rangeInsideHost.getStartOffset(), rangeInsideHost.getEndOffset() - 1);
if (!effectiveRange.isEmpty()) {
Expand Down
10 changes: 8 additions & 2 deletions plugin/src/testFixtures/java/base/PerlLightTestCaseBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -1377,8 +1377,14 @@ protected <T extends PsiElement> T getElementAtCaretWithoutInjection(@NotNull Cl
}

protected @NotNull PsiElement getElementAtCaretWithoutInjection() {
PsiElement result = getFile().getViewProvider().findElementAt(getEditor().getCaretModel().getOffset());
assertNotNull(result);
PsiElement result;
if (getFile().getText().isEmpty()) {
result = getFile();
}
else {
result = getFile().getViewProvider().findElementAt(getEditor().getCaretModel().getOffset());
assertNotNull(result);
}
PsiFile leafFile = result.getContainingFile();
if (InjectedLanguageManager.getInstance(getProject()).isInjectedFragment(leafFile)) {
result = leafFile.getContext();
Expand Down

0 comments on commit c9257b6

Please sign in to comment.