mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-06 06:21:16 +07:00
pass correct max offset + add xml comment characters to wrappable elements
#WEB-16691 fixed
This commit is contained in:
+1
-1
@@ -96,7 +96,7 @@ public abstract class PsiAwareLineWrapPositionStrategy implements LineWrapPositi
|
||||
TextRange textRange = element.getTextRange();
|
||||
int start = Math.max(textRange.getStartOffset(), startOffset);
|
||||
int end = Math.min(textRange.getEndOffset(), endOffset);
|
||||
int result = doCalculateWrapPosition(document, project, start, end, end, false, virtual);
|
||||
int result = doCalculateWrapPosition(document, project, start, end, maxPreferredOffset, false, virtual);
|
||||
if (result >= 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.openapi.editor.LineWrapPositionStrategy;
|
||||
import com.intellij.openapi.editor.PsiAwareDefaultLineWrapPositionStrategy;
|
||||
import com.intellij.psi.TokenType;
|
||||
import com.intellij.psi.xml.XmlElementType;
|
||||
import com.intellij.psi.xml.XmlTokenType;
|
||||
|
||||
/**
|
||||
* {@link LineWrapPositionStrategy} for markup languages like XML, HTML etc.
|
||||
@@ -29,6 +30,6 @@ import com.intellij.psi.xml.XmlElementType;
|
||||
public class MarkupLineWrapPositionStrategy extends PsiAwareDefaultLineWrapPositionStrategy {
|
||||
|
||||
public MarkupLineWrapPositionStrategy() {
|
||||
super(true, XmlElementType.XML_TEXT, TokenType.WHITE_SPACE);
|
||||
super(true, XmlElementType.XML_TEXT, XmlTokenType.XML_COMMENT_CHARACTERS, TokenType.WHITE_SPACE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,23 @@ public class XmlEditorTest extends LightCodeInsightTestCase {
|
||||
"</svg>");
|
||||
}
|
||||
|
||||
public void testHardWrapInComment() throws Exception {
|
||||
configureFromFileText("a.xml",
|
||||
"<!-- Some very long and informative xml comment to trigger hard wrapping indeed. Too short? Dave, let me ask you something. Are hard wraps working? What do we live for? What ice-cream do you like? Who am I?????????????????????????????????????????????????????????????????????????????????????????????????<caret>-->");
|
||||
|
||||
CodeStyleSettings clone = CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings().clone();
|
||||
clone.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = true;
|
||||
try {
|
||||
CodeStyleSettingsManager.getInstance(getProject()).setTemporarySettings(clone);
|
||||
EditorTestUtil.performTypingAction(getEditor(), '?');
|
||||
}
|
||||
finally {
|
||||
CodeStyleSettingsManager.getInstance(getProject()).dropTemporarySettings();
|
||||
}
|
||||
checkResultByText("<!-- Some very long and informative xml comment to trigger hard wrapping indeed. Too short? Dave, let me ask you \n" +
|
||||
"something. Are hard wraps working? What do we live for? What ice-cream do you like? Who am I??????????????????????????????????????????????????????????????????????????????????????????????????-->");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
|
||||
Reference in New Issue
Block a user