From 65635da000d3ad0631b6a73aaf5e554bae79d8af Mon Sep 17 00:00:00 2001 From: Thomas Repnik Date: Sat, 10 Apr 2021 18:53:12 +0200 Subject: [PATCH 1/3] added support for wrapped issue keys --- build.gradle | 2 +- .../intellij/CommitPrefixCheckinHandler.java | 26 +++--- .../intellij/settings/PluginSettings.java | 37 +++++++- .../settings/PluginSettingsConfigurable.java | 26 ++++-- .../intellij/settings/PluginSettingsForm.form | 51 +++++++++-- .../intellij/settings/PluginSettingsForm.java | 25 +++-- src/main/resources/META-INF/plugin.xml | 19 +++- .../CommitPrefixCheckinHandlerTest.java | 91 ++++++++++++++++--- 8 files changed, 222 insertions(+), 55 deletions(-) diff --git a/build.gradle b/build.gradle index 88f162f..482d1d1 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group 'ch.repnik' -version '1.0.6' +version '1.1.0' repositories { mavenCentral() diff --git a/src/main/java/ch/repnik/intellij/CommitPrefixCheckinHandler.java b/src/main/java/ch/repnik/intellij/CommitPrefixCheckinHandler.java index fd0e2ec..fea1687 100644 --- a/src/main/java/ch/repnik/intellij/CommitPrefixCheckinHandler.java +++ b/src/main/java/ch/repnik/intellij/CommitPrefixCheckinHandler.java @@ -59,7 +59,7 @@ private String getNewCommitMessage(){ Optional jiraTicketName = getJiraTicketName(branchName); if (jiraTicketName.isPresent()){ - String newMessage = updatePrefix(jiraTicketName.get(), panel.getCommitMessage(), getCommitMessageDelimiter()); + String newMessage = updatePrefix(jiraTicketName.get(), panel.getCommitMessage(), getWrapLeft(), getWrapRight()); //Sets the value for the new Panel UI return newMessage; } @@ -84,25 +84,25 @@ static String rTrim(String input){ return input.substring(0,i+1); } - static String updatePrefix(String newPrefix, String currentMessage, String commitMessageDelimiter){ + static String updatePrefix(String newPrefix, String currentMessage, String wrapLeft, String wrapRight){ if (currentMessage == null || currentMessage.trim().isEmpty()){ - return newPrefix + commitMessageDelimiter; + return wrapLeft + newPrefix + wrapRight; } //If there is already a commit message with a matching prefix only replace the prefix Matcher matcher = prefixPattern.matcher(currentMessage); if (matcher.find() && - subString(currentMessage,0, matcher.start()).trim().isEmpty() && - (subString(currentMessage, matcher.end(), matcher.end() + commitMessageDelimiter.length()).equals(commitMessageDelimiter) || - subString(currentMessage, matcher.end(), matcher.end() + commitMessageDelimiter.length()).equals(rTrim(commitMessageDelimiter))) + subString(currentMessage,0, matcher.start()).trim().equals(wrapLeft) && + (subString(currentMessage, matcher.end(), matcher.end() + wrapRight.length()).equals(wrapRight) || + subString(currentMessage, matcher.end(), matcher.end() + wrapRight.length()).equals(rTrim(wrapRight))) ){ String start = subString(currentMessage, 0, matcher.start()); - String end = subString(currentMessage, matcher.end() + commitMessageDelimiter.length()); + String end = subString(currentMessage, matcher.end() + wrapRight.length()); - return start + newPrefix + commitMessageDelimiter + end; + return start + newPrefix + wrapRight + end; } - return newPrefix + commitMessageDelimiter + currentMessage; + return wrapLeft + newPrefix + wrapRight + currentMessage; } static String subString(String string, int start){ @@ -127,8 +127,12 @@ static String subString(String string, int start, int end){ - String getCommitMessageDelimiter() { - return PluginSettings.getInstance().getCommitMessageDelimiter(); + String getWrapRight() { + return PluginSettings.getInstance().getWrapRight(); + } + + String getWrapLeft() { + return PluginSettings.getInstance().getWrapLeft(); } private String extractBranchName() { diff --git a/src/main/java/ch/repnik/intellij/settings/PluginSettings.java b/src/main/java/ch/repnik/intellij/settings/PluginSettings.java index 6b70943..e164bb3 100644 --- a/src/main/java/ch/repnik/intellij/settings/PluginSettings.java +++ b/src/main/java/ch/repnik/intellij/settings/PluginSettings.java @@ -6,8 +6,13 @@ public class PluginSettings { private static PluginSettings instance; private static final String SETTING_COMMIT_MESSAGE_DELIMITER = "git.auto.prefix.delimiter"; + private static final String SETTING_WRAP_LEFT = "git.auto.prefix.wrap.left"; + private static final String SETTING_WRAP_RIGHT = "git.auto.prefix.wrap.right"; + private String commitMessageDelimiter; + private String wrapLeft; + private String wrapRight; private PluginSettings(){} @@ -16,10 +21,18 @@ public static PluginSettings getInstance(){ instance = new PluginSettings(); //Set unset Properties - instance.savePropertyIfUnset(SETTING_COMMIT_MESSAGE_DELIMITER, ": "); + PropertiesComponent properties = PropertiesComponent.getInstance(); + + if (properties.isValueSet(SETTING_COMMIT_MESSAGE_DELIMITER)){ + properties.setValue(SETTING_WRAP_RIGHT, properties.getValue(SETTING_COMMIT_MESSAGE_DELIMITER)); + properties.unsetValue(SETTING_COMMIT_MESSAGE_DELIMITER); + } + + PluginSettings.instance.savePropertyIfUnset(SETTING_WRAP_RIGHT, ": "); + PluginSettings.instance.savePropertyIfUnset(SETTING_WRAP_LEFT, ""); //Load all properties - instance.load(); + PluginSettings.instance.load(); } return instance; @@ -34,10 +47,14 @@ private void savePropertyIfUnset(String propertyName, String defaultValue){ private void load(){ this.commitMessageDelimiter = PropertiesComponent.getInstance().getValue(SETTING_COMMIT_MESSAGE_DELIMITER); + this.wrapLeft = PropertiesComponent.getInstance().getValue(SETTING_WRAP_LEFT); + this.wrapRight = PropertiesComponent.getInstance().getValue(SETTING_WRAP_RIGHT); } public void save(){ PropertiesComponent.getInstance().setValue(SETTING_COMMIT_MESSAGE_DELIMITER, this.commitMessageDelimiter); + PropertiesComponent.getInstance().setValue(SETTING_WRAP_LEFT, this.wrapLeft); + PropertiesComponent.getInstance().setValue(SETTING_WRAP_RIGHT, this.wrapRight); } public String getCommitMessageDelimiter() { @@ -48,4 +65,20 @@ public void setCommitMessageDelimiter(String commitMessageDelimiter) { this.commitMessageDelimiter = commitMessageDelimiter; } + public String getWrapLeft() { + return wrapLeft; + } + + public void setWrapLeft(String wrapLeft) { + this.wrapLeft = wrapLeft; + } + + public String getWrapRight() { + return wrapRight; + } + + public void setWrapRight(String wrapRight) { + this.wrapRight = wrapRight; + } + } diff --git a/src/main/java/ch/repnik/intellij/settings/PluginSettingsConfigurable.java b/src/main/java/ch/repnik/intellij/settings/PluginSettingsConfigurable.java index 09a2568..6e64d0e 100644 --- a/src/main/java/ch/repnik/intellij/settings/PluginSettingsConfigurable.java +++ b/src/main/java/ch/repnik/intellij/settings/PluginSettingsConfigurable.java @@ -8,12 +8,11 @@ import javax.swing.*; import java.util.Objects; -import java.util.regex.Matcher; import java.util.regex.Pattern; public class PluginSettingsConfigurable implements SearchableConfigurable { - private Pattern allowedCharsPattern = Pattern.compile("[ :\\_\\-/\\|,\\.]+"); + private Pattern allowedCharsPattern = Pattern.compile("[ \\[\\]\\(\\)\\{\\}:\\_\\-/\\|,\\.]+"); private PluginSettingsForm settingsForm; @@ -36,9 +35,11 @@ public JComponent createComponent() { @Override public boolean isModified() { PluginSettings settings = PluginSettings.getInstance(); - String oldValue = settings.getCommitMessageDelimiter(); - String newValue = settingsForm.getDelimiter(); - return !Objects.equals(oldValue, newValue); + String oldValueRight = settings.getWrapRight(); + String newValueRight = settingsForm.getWrapRight(); + String oldValueLeft = settings.getWrapLeft(); + String newValueLeft = settingsForm.getWrapRight(); + return !Objects.equals(oldValueRight, newValueRight) || !Objects.equals(oldValueLeft, newValueLeft); } @Override @@ -46,7 +47,8 @@ public void apply() throws ConfigurationException { if (settingsForm != null) { if (isModified()) { validate(); - PluginSettings.getInstance().setCommitMessageDelimiter(settingsForm.getDelimiter()); + PluginSettings.getInstance().setWrapRight(settingsForm.getWrapRight()); + PluginSettings.getInstance().setWrapLeft(settingsForm.getWrapLeft()); PluginSettings.getInstance().save(); } } @@ -54,12 +56,16 @@ public void apply() throws ConfigurationException { private void validate() throws ConfigurationException { - if (settingsForm.getDelimiter().isEmpty()){ - throw new ConfigurationException("Delimiter must not be empty", "Validation failed"); + if (settingsForm.getWrapRight().isEmpty()){ + throw new ConfigurationException("Wrap Right/Delimiter must not be empty", "Validation failed"); } - if (!allowedCharsPattern.matcher(settingsForm.getDelimiter()).matches()){ - throw new ConfigurationException("Delimiter can only contain following chars: \" :_-/|,.\"", "Validation failed"); + if (!allowedCharsPattern.matcher(settingsForm.getWrapRight()).matches()){ + throw new ConfigurationException("Wrap Right/Delimiter can only contain following chars: \" [](){}:_-/|,.\"", "Validation failed"); + } + + if (!allowedCharsPattern.matcher(settingsForm.getWrapLeft()).matches()){ + throw new ConfigurationException("Wrap Left can only contain following chars: \" [](){}:_-/|,.\"", "Validation failed"); } } diff --git a/src/main/java/ch/repnik/intellij/settings/PluginSettingsForm.form b/src/main/java/ch/repnik/intellij/settings/PluginSettingsForm.form index 65c4d5f..55fabd8 100644 --- a/src/main/java/ch/repnik/intellij/settings/PluginSettingsForm.form +++ b/src/main/java/ch/repnik/intellij/settings/PluginSettingsForm.form @@ -1,6 +1,6 @@
- + @@ -10,15 +10,15 @@ - + - + - + - + @@ -28,17 +28,48 @@ - + - + + + + + + + + + + + + + + + + + + + + - + - + - + + + + + + + + + + + + + diff --git a/src/main/java/ch/repnik/intellij/settings/PluginSettingsForm.java b/src/main/java/ch/repnik/intellij/settings/PluginSettingsForm.java index 45be013..04d5735 100644 --- a/src/main/java/ch/repnik/intellij/settings/PluginSettingsForm.java +++ b/src/main/java/ch/repnik/intellij/settings/PluginSettingsForm.java @@ -1,17 +1,27 @@ package ch.repnik.intellij.settings; import javax.swing.*; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; public class PluginSettingsForm { private JPanel mainPanel; - private JTextField txtDelimiter; + private JTextField txtWrapLeft; + private JTextField txtWrapRight; public PluginSettingsForm(){ - txtDelimiter.addKeyListener(new KeyAdapter() { + txtWrapLeft.addKeyListener(new KeyAdapter() { public void keyTyped(KeyEvent e) { - if (txtDelimiter.getText().length() >= 5 ) // limit textfield to 5 characters + if (txtWrapLeft.getText().length() >= 5 ) // limit textfield to 5 characters + e.consume(); + } + }); + + txtWrapRight.addKeyListener(new KeyAdapter() { + public void keyTyped(KeyEvent e) { + if (txtWrapRight.getText().length() >= 5 ) // limit textfield to 5 characters e.consume(); } }); @@ -21,11 +31,14 @@ public JPanel getPanel(){ return mainPanel; } - public String getDelimiter(){ - return txtDelimiter.getText(); + public String getWrapRight(){ + return txtWrapRight.getText(); } + public String getWrapLeft() {return txtWrapLeft.getText();} + public void resetEditorFrom(PluginSettings settings){ - this.txtDelimiter.setText(settings.getCommitMessageDelimiter()); + this.txtWrapLeft.setText(settings.getWrapLeft()); + this.txtWrapRight.setText(settings.getWrapRight()); } } diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index c307ce5..335dad6 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -1,49 +1,60 @@ commit-prefix-plugin Git Auto Prefix - 1.0.6 + 1.1.0 Thomas Repnik - Added support for IntelliJ 2021.1 + Added support for wrapping the issue key Automatically set the jira issue key (of the current branch name) as prefix for the commit message
- It's possible to choose your own delimiter between the issue key and commit message +
    +
  • Choose your own delimiter between the issue key and commit message
  • +
  • Wrap the issue key if necessary
  • +

- + + + + + + + + +
Branch NameCommit prefixCommit prefix (with delimiter)Commit prefix (wrapped)
master no actionno action
bugfix/ABC-1234-app-not-working ABC-1234:[ABC-1234]
feature/ABC-1234-app-not-working ABC-1234:[ABC-1234]
release/ABC-1234-app-not-working ABC-1234:[ABC-1234]
someOtherType/ABC-1234-app-not-working ABC-1234:[ABC-1234]
ABC-1234-app-not-working ABC-1234:[ABC-1234]
ABC-1234 ABC-1234:[ABC-1234]
]]>
diff --git a/src/test/java/ch/repnik/intellij/CommitPrefixCheckinHandlerTest.java b/src/test/java/ch/repnik/intellij/CommitPrefixCheckinHandlerTest.java index f01337d..33b6c7b 100644 --- a/src/test/java/ch/repnik/intellij/CommitPrefixCheckinHandlerTest.java +++ b/src/test/java/ch/repnik/intellij/CommitPrefixCheckinHandlerTest.java @@ -11,64 +11,133 @@ class CommitPrefixCheckinHandlerTest { @Test public void updatePrefix_existingMessage_updatedCorrectly() { - String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", "XYXY-837292: This is my text", ": "); + String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", "XYXY-837292: This is my text", "", ": "); assertThat(result, is("ABC-1234: This is my text")); } @Test public void updatePrefix_delimiterWithoutMessage_updatedCorrectly() { - String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", "XYXY-837292:", ": "); + String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", "XYXY-837292:","", ": "); assertThat(result, is("ABC-1234: ")); } @Test public void updatePrefix_wrongDelimiter_issueNotRecognized() { - String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", "XYXY-837292: This is my text", " | "); + String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", "XYXY-837292: This is my text","", " | "); assertThat(result, is("ABC-1234 | XYXY-837292: This is my text")); } @Test public void updatePrefix_specialDelimiter_updatedCorrectly() { - String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", null, " :_-/|,."); - assertThat(result, is("ABC-1234 :_-/|,.")); + String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", null," [](){}:_-/|,.", " [](){}:_-/|,."); + assertThat(result, is(" [](){}:_-/|,.ABC-1234 [](){}:_-/|,.")); } @Test public void updatePrefix_doubledPattern_updatedCorrectly() { - String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", "XYXY-837292: XYZ-11 This is my text", ": "); + String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", "XYXY-837292: XYZ-11 This is my text","", ": "); assertThat(result, is("ABC-1234: XYZ-11 This is my text")); } @Test public void updatePrefix_null_updatedCorrectly() { - String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", null, ": "); + String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", null,"", ": "); assertThat(result, is("ABC-1234: ")); } @Test public void updatePrefix_emptyMessage_updatedCorrectly() { - String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", "", ": "); + String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", "","", ": "); assertThat(result, is("ABC-1234: ")); } @Test public void updatePrefix_blankMessage_updatedCorrectly() { - String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", " ", ": "); + String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", " ","", ": "); assertThat(result, is("ABC-1234: ")); } @Test public void updatePrefix_existingMessageWithBlanks_updatedCorrectly() { - String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", " XYXY-837292: This is a Test ", ": "); + String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", " XYXY-837292: This is a Test ","", ": "); assertThat(result, is(" ABC-1234: This is a Test ")); } @Test public void updatePrefix_existingMessageWithPrefixInText_updatedCorrectly() { - String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", " According to issue XYXY-837292: this fix... ", ": "); + String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", " According to issue XYXY-837292: this fix... ","", ": "); assertThat(result, is("ABC-1234: According to issue XYXY-837292: this fix... ")); } + + + //TESTS WITH WRAP LEFT + @Test + public void updatePrefix_existingMessageWrapLeft_updatedCorrectly() { + String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", "[XYXY-837292]: This is my text", "[", "]: "); + assertThat(result, is("[ABC-1234]: This is my text")); + } + + @Test + public void updatePrefix_delimiterWithoutMessageWrapLeft_updatedCorrectly() { + String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", "[XYXY-837292]:","[", "]: "); + assertThat(result, is("[ABC-1234]: ")); + } + + @Test + public void updatePrefix_wrongDelimiterWrapLeft_issueNotRecognized() { + String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", "[XYXY-837292]: This is my text","[", " | "); + assertThat(result, is("[ABC-1234 | [XYXY-837292]: This is my text")); + } + + @Test + public void updatePrefix_specialDelimiterWrapLeft_updatedCorrectly() { + String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", null," [](){}:_-/|,.", " [](){}:_-/|,."); + assertThat(result, is(" [](){}:_-/|,.ABC-1234 [](){}:_-/|,.")); + } + + @Test + public void updatePrefix_doubledPatternWrapLeft_updatedCorrectly() { + String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", "[XYXY-837292]: XYZ-11 This is my text","[", "]: "); + assertThat(result, is("[ABC-1234]: XYZ-11 This is my text")); + } + + @Test + public void updatePrefix_nullWrapLeft_updatedCorrectly() { + String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", null,"[", "]: "); + assertThat(result, is("[ABC-1234]: ")); + } + + @Test + public void updatePrefix_emptyMessageWrapLeft_updatedCorrectly() { + String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", "","[", "]: "); + assertThat(result, is("[ABC-1234]: ")); + } + + @Test + public void updatePrefix_blankMessageWrapLeft_updatedCorrectly() { + String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", " ","[", "]: "); + assertThat(result, is("[ABC-1234]: ")); + } + + @Test + public void updatePrefix_existingMessageWithBlanksWrapLeft_updatedCorrectly() { + String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", " [XYXY-837292]: This is a Test ","[", "]: "); + assertThat(result, is(" [ABC-1234]: This is a Test ")); + } + + @Test + public void updatePrefix_existingMessageWithPrefixInTextWrapLeft_updatedCorrectly() { + String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", " According to issue XYXY-837292: this fix... ","[", "]: "); + assertThat(result, is("[ABC-1234]: According to issue XYXY-837292: this fix... ")); + } + + @Test + public void updatePrefix_noMessageButWrappedInBlanks_updatedCorrectly() { + String result = CommitPrefixCheckinHandler.updatePrefix("ABC-1234", null," ", " "); + assertThat(result, is(" ABC-1234 ")); + } + @Test public void getJiraTicketName_withoutBranchType_retunsJiraTicket() { Optional result = CommitPrefixCheckinHandler.getJiraTicketName("ABC-1234-app-not-working"); From 85fc61c27bf2772dc0c75fea7de091821648358f Mon Sep 17 00:00:00 2001 From: Thomas Repnik Date: Sat, 10 Apr 2021 18:59:26 +0200 Subject: [PATCH 2/3] updated README.md --- README.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 9ed47de..fcc013c 100644 --- a/README.md +++ b/README.md @@ -8,17 +8,18 @@ Plugin can be downloaded whithin IntelliJ or on the Jetbrains [Plugin Site](http * Automatically change the commit prefix if switching branches * If intellij is suggesting a (previous) commit message, only the prefix will be updated * Set your custom delimiter between the issue key and the commit message (Default ": ") +* Wrap the issue key as you like ## Samples Following prefix for commit messages will automatically be generated: -| Branch name | Commit prefix | -|---------------------------------------- |--------------- | -| master | no action | -| bugfix/ABC-1234-app-not-working | ABC-1234: | -| feature/ABC-1234-app-not-working | ABC-1234: | -| release/ABC-1234-app-not-working | ABC-1234: | -| someOtherType/ABC-1234-app-not-working | ABC-1234: | -| ABC-1234-app-not-working | ABC-1234: | -| ABC-1234 | ABC-1234: | +| Branch name | Commit prefix (with delimiter) | Commit prefix (wrapped) +|---------------------------------------- |--------------- |--------------- +| master | no action | no action +| bugfix/ABC-1234-app-not-working | ABC-1234: | [ABC-1234] +| feature/ABC-1234-app-not-working | ABC-1234: | [ABC-1234] +| release/ABC-1234-app-not-working | ABC-1234: | [ABC-1234] +| someOtherType/ABC-1234-app-not-working | ABC-1234: | [ABC-1234] +| ABC-1234-app-not-working | ABC-1234: | [ABC-1234] +| ABC-1234 | ABC-1234: | [ABC-1234] From 4f99adfcab06477ea730b3db689c5fe9afe98d4e Mon Sep 17 00:00:00 2001 From: Thomas Repnik Date: Mon, 12 Apr 2021 16:47:00 +0200 Subject: [PATCH 3/3] fixed validation --- .../ch/repnik/intellij/settings/PluginSettingsConfigurable.java | 2 +- .../java/ch/repnik/intellij/settings/PluginSettingsForm.java | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/ch/repnik/intellij/settings/PluginSettingsConfigurable.java b/src/main/java/ch/repnik/intellij/settings/PluginSettingsConfigurable.java index 6e64d0e..aa784f4 100644 --- a/src/main/java/ch/repnik/intellij/settings/PluginSettingsConfigurable.java +++ b/src/main/java/ch/repnik/intellij/settings/PluginSettingsConfigurable.java @@ -64,7 +64,7 @@ private void validate() throws ConfigurationException { throw new ConfigurationException("Wrap Right/Delimiter can only contain following chars: \" [](){}:_-/|,.\"", "Validation failed"); } - if (!allowedCharsPattern.matcher(settingsForm.getWrapLeft()).matches()){ + if (!settingsForm.getWrapLeft().isEmpty() && !allowedCharsPattern.matcher(settingsForm.getWrapLeft()).matches()){ throw new ConfigurationException("Wrap Left can only contain following chars: \" [](){}:_-/|,.\"", "Validation failed"); } } diff --git a/src/main/java/ch/repnik/intellij/settings/PluginSettingsForm.java b/src/main/java/ch/repnik/intellij/settings/PluginSettingsForm.java index 04d5735..2e28986 100644 --- a/src/main/java/ch/repnik/intellij/settings/PluginSettingsForm.java +++ b/src/main/java/ch/repnik/intellij/settings/PluginSettingsForm.java @@ -1,8 +1,6 @@ package ch.repnik.intellij.settings; import javax.swing.*; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent;