mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-113332 Typing an attribute in XML/HTML files ends up with corrupted XML
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="247ce" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="247ce" layout-manager="GridLayoutManager" row-count="6" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="8" fill="2" indent="0" use-parent-layout="false"/>
|
||||
@@ -54,12 +54,20 @@
|
||||
</component>
|
||||
<component id="49db6" class="com.intellij.ui.components.JBCheckBox" binding="mySelectWholeSelectorOnDoubleClick">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Select whole CSS selector suffix on double click"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="8169b" class="com.intellij.ui.components.JBCheckBox" binding="myAddQuotasForAttributeValue">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Automatically add quotas for attribute value"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<vspacer id="e0bcf">
|
||||
|
||||
@@ -32,6 +32,7 @@ public class WebEditorOptionsProvider implements EditorOptionsProvider {
|
||||
private JCheckBox myAutomaticallyInsertRequiredSubTagsCheckBox;
|
||||
private JCheckBox myAutomaticallyStartAttributeAfterCheckBox;
|
||||
private JBCheckBox mySelectWholeSelectorOnDoubleClick;
|
||||
private JBCheckBox myAddQuotasForAttributeValue;
|
||||
|
||||
|
||||
public String getDisplayName() {
|
||||
@@ -46,15 +47,14 @@ public class WebEditorOptionsProvider implements EditorOptionsProvider {
|
||||
return myWholePanel;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean isModified() {
|
||||
final WebEditorOptions xmlEditorOptions = WebEditorOptions.getInstance();
|
||||
return xmlEditorOptions.isAutomaticallyInsertClosingTag() != myAutomaticallyInsertClosingTagCheckBox.isSelected() ||
|
||||
xmlEditorOptions.isAutomaticallyInsertRequiredAttributes() != myAutomaticallyInsertRequiredAttributesCheckBox.isSelected() ||
|
||||
xmlEditorOptions.isAutomaticallyStartAttribute() != myAutomaticallyStartAttributeAfterCheckBox.isSelected() ||
|
||||
xmlEditorOptions.isSelectWholeCssSelectorSuffixOnDoubleClick() != mySelectWholeSelectorOnDoubleClick.isSelected() ||
|
||||
xmlEditorOptions.isAutomaticallyInsertRequiredSubTags() != myAutomaticallyInsertRequiredSubTagsCheckBox.isSelected();
|
||||
xmlEditorOptions.isAutomaticallyInsertRequiredSubTags() != myAutomaticallyInsertRequiredSubTagsCheckBox.isSelected() ||
|
||||
xmlEditorOptions.isInsertQuotesForAttributeValue() != myAddQuotasForAttributeValue.isSelected();
|
||||
}
|
||||
|
||||
public void apply() throws ConfigurationException {
|
||||
@@ -64,6 +64,7 @@ public class WebEditorOptionsProvider implements EditorOptionsProvider {
|
||||
xmlEditorOptions.setAutomaticallyInsertRequiredSubTags(myAutomaticallyInsertRequiredSubTagsCheckBox.isSelected());
|
||||
xmlEditorOptions.setAutomaticallyStartAttribute(myAutomaticallyStartAttributeAfterCheckBox.isSelected());
|
||||
xmlEditorOptions.setSelectWholeCssSelectorSuffixOnDoubleClick(mySelectWholeSelectorOnDoubleClick.isSelected());
|
||||
xmlEditorOptions.setInsertQuotesForAttributeValue(myAddQuotasForAttributeValue.isSelected());
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
@@ -73,6 +74,7 @@ public class WebEditorOptionsProvider implements EditorOptionsProvider {
|
||||
myAutomaticallyInsertRequiredSubTagsCheckBox.setSelected(xmlEditorOptions.isAutomaticallyInsertRequiredSubTags());
|
||||
myAutomaticallyStartAttributeAfterCheckBox.setSelected(xmlEditorOptions.isAutomaticallyStartAttribute());
|
||||
mySelectWholeSelectorOnDoubleClick.setSelected(xmlEditorOptions.isSelectWholeCssSelectorSuffixOnDoubleClick());
|
||||
myAddQuotasForAttributeValue.setSelected(xmlEditorOptions.isInsertQuotesForAttributeValue());
|
||||
}
|
||||
|
||||
public void disposeUIResources() {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.editorActions;
|
||||
|
||||
import com.intellij.application.options.editor.WebEditorOptions;
|
||||
import com.intellij.codeInsight.AutoPopupController;
|
||||
import com.intellij.lang.xml.XMLLanguage;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
@@ -34,12 +35,15 @@ public class XmlEqTypedHandler extends TypedHandlerDelegate {
|
||||
Editor editor,
|
||||
PsiFile file,
|
||||
FileType fileType) {
|
||||
boolean inXml = file.getLanguage() instanceof XMLLanguage || file.getViewProvider().getBaseLanguage() instanceof XMLLanguage;
|
||||
if (c == '=' && inXml) {
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
PsiElement at = file.findElementAt(offset - 1);
|
||||
PsiElement atParent = at != null ? at.getParent() : null;
|
||||
needToInsertQuotes = atParent instanceof XmlAttribute && ((XmlAttribute)atParent).getValueElement() == null;
|
||||
|
||||
if (WebEditorOptions.getInstance().isInsertQuotesForAttributeValue()) {
|
||||
boolean inXml = file.getLanguage() instanceof XMLLanguage || file.getViewProvider().getBaseLanguage() instanceof XMLLanguage;
|
||||
if (c == '=' && inXml) {
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
PsiElement at = file.findElementAt(offset - 1);
|
||||
PsiElement atParent = at != null ? at.getParent() : null;
|
||||
needToInsertQuotes = atParent instanceof XmlAttribute && ((XmlAttribute)atParent).getValueElement() == null;
|
||||
}
|
||||
}
|
||||
|
||||
return super.beforeCharTyped(c, project, editor, file, fileType);
|
||||
|
||||
+10
-3
@@ -45,6 +45,7 @@ public class WebEditorOptions implements PersistentStateComponent<WebEditorOptio
|
||||
private boolean myAutomaticallyInsertRequiredAttributes = true;
|
||||
private boolean myAutomaticallyInsertRequiredSubTags = true;
|
||||
private boolean myAutomaticallyStartAttribute = true;
|
||||
private boolean myInsertQuotesForAttributeValue = true;
|
||||
|
||||
private boolean myTagTreeHighlightingEnabled = true;
|
||||
private int myTagTreeHighlightingLevelCount = 6;
|
||||
@@ -98,9 +99,7 @@ public class WebEditorOptions implements PersistentStateComponent<WebEditorOptio
|
||||
myAutomaticallyInsertClosingTag = automaticallyInsertClosingTag;
|
||||
}
|
||||
|
||||
public boolean isAutomaticallyInsertRequiredAttributes() {
|
||||
return myAutomaticallyInsertRequiredAttributes;
|
||||
}
|
||||
public boolean isAutomaticallyInsertRequiredAttributes() { return myAutomaticallyInsertRequiredAttributes; }
|
||||
|
||||
public void setAutomaticallyInsertRequiredAttributes(final boolean automaticallyInsertRequiredAttributes) {
|
||||
myAutomaticallyInsertRequiredAttributes = automaticallyInsertRequiredAttributes;
|
||||
@@ -186,4 +185,12 @@ public class WebEditorOptions implements PersistentStateComponent<WebEditorOptio
|
||||
public void setSelectWholeCssSelectorSuffixOnDoubleClick(boolean selectWholeCssSelectorSuffixOnDoubleClick) {
|
||||
mySelectWholeCssSelectorSuffixOnDoubleClick = selectWholeCssSelectorSuffixOnDoubleClick;
|
||||
}
|
||||
|
||||
public boolean isInsertQuotesForAttributeValue() {
|
||||
return myInsertQuotesForAttributeValue;
|
||||
}
|
||||
|
||||
public void setInsertQuotesForAttributeValue(boolean insertQuotesForAttributeValue) {
|
||||
myInsertQuotesForAttributeValue = insertQuotesForAttributeValue;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user