mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
line comment action: correct for the case of embedded part on the line
- when the selected line contains embedded fragment with the other language, line still can be commented with the wrapping language comment symbols WEB-29018 vue files with jade/pug as lang - comments not working!
This commit is contained in:
@@ -332,11 +332,20 @@ public class PsiTreeUtil {
|
||||
|
||||
@Nullable
|
||||
public static PsiElement findFirstParent(@Nullable PsiElement element, boolean strict, Condition<PsiElement> condition) {
|
||||
//noinspection unchecked
|
||||
return findFirstParent(element, strict, condition, Condition.FALSE);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiElement findFirstParent(@Nullable PsiElement element, boolean strict,
|
||||
@NotNull final Condition<PsiElement> condition,
|
||||
@NotNull final Condition<PsiElement> stopCondition) {
|
||||
if (strict && element != null) {
|
||||
element = element.getParent();
|
||||
}
|
||||
|
||||
while (element != null) {
|
||||
if (stopCondition.value(element)) return null;
|
||||
if (condition.value(element)) {
|
||||
return element;
|
||||
}
|
||||
|
||||
@@ -133,7 +133,14 @@ public class PsiUtilBase extends PsiUtilCore implements PsiEditorUtil {
|
||||
lang = language;
|
||||
}
|
||||
else if (lang != language) {
|
||||
return null;
|
||||
// correctly process the case when leaf element is a part of embedded fragment, but it is totally contained inside
|
||||
// "parent" language
|
||||
Language finalLang = lang;
|
||||
final TextRange range = new TextRange(start, end);
|
||||
final PsiElement wrappingParent = PsiTreeUtil.findFirstParent(
|
||||
elt, false, element -> file.equals(element.getContainingFile()) && finalLang.equals(element.getLanguage()),
|
||||
element -> element.getTextRange() != null && !range.contains(element.getTextRange()));
|
||||
if (wrappingParent == null) return null;
|
||||
}
|
||||
}
|
||||
TextRange range = elt.getTextRange();
|
||||
|
||||
Reference in New Issue
Block a user