Skip to content

Commit

Permalink
#2894 handled empty heredoc injection (need to adjust indentation for…
Browse files Browse the repository at this point in the history
… the first element)
  • Loading branch information
hurricup committed Sep 15, 2024
1 parent adbfd88 commit 29f0e1f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2020 Alexandr Evstigneev
* Copyright 2015-2024 Alexandr Evstigneev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -35,8 +35,17 @@ public boolean isOneLine() {

@Override
public boolean decode(@NotNull TextRange rangeInsideHost, @NotNull StringBuilder outChars) {
outChars.append(rangeInsideHost.subSequence(myHost.getNode().getChars()));
return true;
var hostTextLength = myHost.getTextLength();
var effectiveRange = hostTextLength < rangeInsideHost.getEndOffset() ?
rangeInsideHost :
TextRange.create(rangeInsideHost.getStartOffset(), rangeInsideHost.getEndOffset() - 1);
if (!effectiveRange.isEmpty()) {
outChars.append(rangeInsideHost.subSequence(myHost.getNode().getChars()));
return true;
}
else {
return false;
}
}

@Override
Expand Down
10 changes: 1 addition & 9 deletions plugin/src/test/java/intellilang/PerlQuickEditTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,7 @@ class PerlQuickEditTest : PerlLightTestCase() {
sub foo{
say <<~HTML;
hello there
<div>
<html>
</html>
</div>
hello there
HTML
}""".trimIndent(), originalEditor.document.text
)
Expand Down

0 comments on commit 29f0e1f

Please sign in to comment.