Skip to content

Commit 2f0d4b0

Browse files
committed
Fix: Apply code review
1 parent fae1e47 commit 2f0d4b0

File tree

4 files changed

+149
-122
lines changed

4 files changed

+149
-122
lines changed

src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvEditorSettings.java

Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ public String getDisplay() {
7575
public static final class OptionSet {
7676
public String CURRENT_PLUGIN_VERSION;
7777

78-
public boolean CARET_ROW_SHOWN;
79-
public boolean USE_SOFT_WRAP;
78+
public boolean CARET_ROW_SHOWN = true;
79+
public boolean USE_SOFT_WRAP = false;
8080
public boolean HIGHTLIGHT_TAB_SEPARATOR = true;
8181
public boolean SHOW_INFO_BALLOON = true;
8282
public String TAB_HIGHLIGHT_COLOR = "-7984";
@@ -100,18 +100,6 @@ public static final class OptionSet {
100100
private boolean isInitialized = false;
101101

102102
public OptionSet() {}
103-
104-
public void init() {
105-
if (this.isInitialized) {
106-
return;
107-
}
108-
109-
EditorSettingsExternalizable editorSettingsExternalizable = EditorSettingsExternalizable.getInstance();
110-
CARET_ROW_SHOWN = editorSettingsExternalizable == null ? true : editorSettingsExternalizable.isCaretRowShown();
111-
USE_SOFT_WRAP = editorSettingsExternalizable == null ? false : editorSettingsExternalizable.isUseSoftWraps();
112-
113-
this.isInitialized = true;
114-
}
115103
}
116104

117105
private OptionSet myOptions = new OptionSet();
@@ -138,7 +126,6 @@ public void removePropertyChangeListener(PropertyChangeListener listener) {
138126

139127
@Override
140128
public OptionSet getState() {
141-
this.myOptions.init();
142129
return this.myOptions;
143130
}
144131

@@ -150,39 +137,39 @@ public void loadState(@NotNull OptionSet state) {
150137
/*********** Settings section **********/
151138

152139
public boolean isCaretRowShown() {
153-
return this.myOptions.CARET_ROW_SHOWN;
140+
return getState().CARET_ROW_SHOWN;
154141
}
155142

156143
public void setCaretRowShown(boolean caretRowShown) {
157144
getState().CARET_ROW_SHOWN = caretRowShown;
158145
}
159146

160147
public boolean isUseSoftWraps() {
161-
return this.myOptions.USE_SOFT_WRAP;
148+
return getState().USE_SOFT_WRAP;
162149
}
163150

164151
public void setUseSoftWraps(boolean useSoftWraps) {
165152
getState().USE_SOFT_WRAP = useSoftWraps;
166153
}
167154

168155
public boolean isHighlightTabSeparator() {
169-
return this.myOptions.HIGHTLIGHT_TAB_SEPARATOR;
156+
return getState().HIGHTLIGHT_TAB_SEPARATOR;
170157
}
171158

172159
public void setHighlightTabSeparator(boolean highlightTabSeparator) {
173160
getState().HIGHTLIGHT_TAB_SEPARATOR = highlightTabSeparator;
174161
}
175162

176163
public boolean isShowInfoBalloon() {
177-
return this.myOptions.SHOW_INFO_BALLOON;
164+
return getState().SHOW_INFO_BALLOON;
178165
}
179166

180167
public void setShowInfoBalloon(boolean showInfoBalloon) {
181168
getState().SHOW_INFO_BALLOON = showInfoBalloon;
182169
}
183170

184171
public Color getTabHighlightColor() {
185-
String color = this.myOptions.TAB_HIGHLIGHT_COLOR;
172+
String color = getState().TAB_HIGHLIGHT_COLOR;
186173
try {
187174
return color == null || color.isEmpty() ? null : Color.decode(color);
188175
} catch (NumberFormatException exc) {
@@ -195,61 +182,56 @@ public void setTabHighlightColor(Color color) {
195182
}
196183

197184
public EditorPrio getEditorPrio() {
198-
// Important: avoid triggering OptionSet.init() here because it consults
199-
// EditorSettingsExternalizable on first access which may require UI/EDT
200-
// initialization. The file editor providers call this method from background
201-
// threads during provider discovery, and any slow or blocking initialization
202-
// can lead to timeouts when the IDE checks providers.
203-
// Access the current option directly to keep provider checks fast and non-blocking.
204-
return this.myOptions.EDITOR_PRIO;
185+
return getState().EDITOR_PRIO;
205186
}
206187

207188
public void setEditorPrio(EditorPrio editorPrio) {
208189
getState().EDITOR_PRIO = editorPrio;
209190
}
210191

211192
public boolean showTableEditorInfoPanel() {
212-
return this.myOptions.SHOW_TABLE_EDITOR_INFO_PANEL;
193+
return getState().SHOW_TABLE_EDITOR_INFO_PANEL;
213194
}
214195

215196
public void showTableEditorInfoPanel(boolean showInfoPanel) {
216197
getState().SHOW_TABLE_EDITOR_INFO_PANEL = showInfoPanel;
217198
}
218199

219200
public int getTableEditorRowHeight() {
220-
return this.myOptions.TABLE_EDITOR_ROW_HEIGHT;
201+
int rowHeight = getState().TABLE_EDITOR_ROW_HEIGHT;
202+
return rowHeight > TABLE_EDITOR_ROW_HEIGHT_MAX || rowHeight < TABLE_EDITOR_ROW_HEIGHT_MIN ? TABLE_EDITOR_ROW_HEIGHT_DEFAULT : rowHeight;
221203
}
222204

223205
public void setTableEditorRowHeight(int rowHeight) {
224206
getState().TABLE_EDITOR_ROW_HEIGHT = rowHeight > TABLE_EDITOR_ROW_HEIGHT_MAX || rowHeight < TABLE_EDITOR_ROW_HEIGHT_MIN ? TABLE_EDITOR_ROW_HEIGHT_DEFAULT : rowHeight;
225207
}
226208

227209
public boolean isQuotingEnforced() {
228-
return this.myOptions.QUOTING_ENFORCED;
210+
return getState().QUOTING_ENFORCED;
229211
}
230212

231213
public void setQuotingEnforced(boolean quotingEnforced) {
232214
getState().QUOTING_ENFORCED = quotingEnforced;
233215
}
234216

235217
public boolean isZeroBasedColumnNumbering() {
236-
return this.myOptions.ZERO_BASED_COLUMN_NUMBERING;
218+
return getState().ZERO_BASED_COLUMN_NUMBERING;
237219
}
238220

239221
public void setZeroBasedColumnNumbering(boolean zeroBasedColumnNumbering) {
240222
getState().ZERO_BASED_COLUMN_NUMBERING = zeroBasedColumnNumbering;
241223
}
242224

243225
public int getTableAutoMaxColumnWidth() {
244-
return this.myOptions.TABLE_AUTO_MAX_COLUMN_WIDTH;
226+
return getState().TABLE_AUTO_MAX_COLUMN_WIDTH;
245227
}
246228

247229
public void setTableAutoMaxColumnWidth(int tableAutoMaxColumnWidth) {
248230
getState().TABLE_AUTO_MAX_COLUMN_WIDTH = tableAutoMaxColumnWidth;
249231
}
250232

251233
public int getTableDefaultColumnWidth() {
252-
return this.myOptions.TABLE_DEFAULT_COLUMN_WIDTH;
234+
return getState().TABLE_DEFAULT_COLUMN_WIDTH;
253235
}
254236

255237
public void setTableDefaultColumnWidth(int tableDefaultColumnWidth) {
@@ -265,7 +247,7 @@ public void setDefaultEscapeCharacter(CsvEscapeCharacter defaultEscapeCharacter)
265247
}
266248

267249
public CsvEscapeCharacter getDefaultEscapeCharacter() {
268-
CsvEscapeCharacter csvValueSeparator = this.myOptions.DEFAULT_ESCAPE_CHARACTER;
250+
CsvEscapeCharacter csvValueSeparator = getState().DEFAULT_ESCAPE_CHARACTER;
269251
return csvValueSeparator == null ? ESCAPE_CHARACTER_DEFAULT : csvValueSeparator;
270252
}
271253

@@ -278,7 +260,7 @@ public void setDefaultValueSeparator(CsvValueSeparator defaultValueSeparator) {
278260
}
279261

280262
public CsvValueSeparator getDefaultValueSeparator() {
281-
CsvValueSeparator csvValueSeparator = this.myOptions.DEFAULT_VALUE_SEPARATOR;
263+
CsvValueSeparator csvValueSeparator = getState().DEFAULT_VALUE_SEPARATOR;
282264
return csvValueSeparator == null ? VALUE_SEPARATOR_DEFAULT : csvValueSeparator;
283265
}
284266

@@ -287,7 +269,7 @@ public void setKeepTrailingSpaces(boolean keepTrailingSpaces) {
287269
}
288270

289271
public boolean getKeepTrailingSpaces() {
290-
return this.myOptions.KEEP_TRAILING_SPACES;
272+
return getState().KEEP_TRAILING_SPACES;
291273
}
292274

293275
public void setCommentIndicator(String commentIndicator) {
@@ -299,11 +281,11 @@ public void setCommentIndicator(String commentIndicator) {
299281
}
300282

301283
public String getCommentIndicator() {
302-
return this.myOptions.COMMENT_INDICATOR;
284+
return getState().COMMENT_INDICATOR;
303285
}
304286

305287
public ValueColoring getValueColoring() {
306-
return this.myOptions.VALUE_COLORING;
288+
return getState().VALUE_COLORING;
307289
}
308290

309291
public void setValueColoring(ValueColoring valueColoring) {
@@ -315,7 +297,7 @@ public void setValueColoring(ValueColoring valueColoring) {
315297
}
316298

317299
public boolean isAutoDetectValueSeparator() {
318-
return this.myOptions.AUTO_DETECT_VALUE_SEPARATOR;
300+
return getState().AUTO_DETECT_VALUE_SEPARATOR;
319301
}
320302

321303
public void setAutoDetectValueSeparator(boolean autoDetectValueSeparator) {

src/test/java/net/seesharpsoft/intellij/plugins/csv/CsvGithubIssueSubmitterTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ public void printStackTrace(PrintWriter writer) {
2828

2929
private CsvGithubIssueSubmitterSubClass classUnderTest = new CsvGithubIssueSubmitterSubClass();
3030

31-
public String callSearchExistingIssues(String title) throws Exception {
32-
return classUnderTest.searchExistingIssues(null, title, null);
33-
}
34-
3531
public void testSearchExistingIssuesNeedle() throws Exception {
3632
assertEquals("crash", classUnderTest.searchExistingIssuesNeedle(null));
3733
assertEquals("crash", classUnderTest.searchExistingIssuesNeedle(""));

0 commit comments

Comments
 (0)