mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix too strict hints offset condition
Required for RUBY-20196, see `ParamHintsTest.testRestAndBlock`
This commit is contained in:
@@ -94,8 +94,8 @@ public class ParameterHintsPass extends EditorBoundHighlightingPass {
|
||||
|
||||
inlays.forEach((hint) -> {
|
||||
int offset = hint.getOffset();
|
||||
TextRange rootRange = myRootElement.getTextRange();
|
||||
if (offset <= rootRange.getStartOffset() || offset >= rootRange.getEndOffset()) return;
|
||||
if (!canShowHintsAtOffset(offset)) return;
|
||||
|
||||
String presentation = provider.getInlayPresentation(hint.getText());
|
||||
if (hint.isShowOnlyIfExistedBefore()) {
|
||||
myShowOnlyIfExistedBeforeHints.put(offset, presentation);
|
||||
@@ -138,6 +138,21 @@ public class ParameterHintsPass extends EditorBoundHighlightingPass {
|
||||
|
||||
return ContainerUtil.filter(inlays, (hint) -> manager.isParameterHint(hint));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adding hints on the borders of root element (at startOffset or endOffset)
|
||||
* is allowed only in the case when root element is a document
|
||||
*
|
||||
* @return true iff a given offset can be used for hint rendering
|
||||
*/
|
||||
private boolean canShowHintsAtOffset(int offset) {
|
||||
TextRange rootRange = myRootElement.getTextRange();
|
||||
|
||||
if (!rootRange.containsOffset(offset)) return false;
|
||||
if (offset > rootRange.getStartOffset() && offset < rootRange.getEndOffset()) return true;
|
||||
|
||||
return myDocument != null && myDocument.getTextLength() == rootRange.getLength();
|
||||
}
|
||||
|
||||
public static class HintData {
|
||||
public final String presentationText;
|
||||
|
||||
Reference in New Issue
Block a user