Skip to content

Commit 2a51cb9

Browse files
committed
[FIX] code quality review
1 parent eff5bf6 commit 2a51cb9

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsProvider.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ public class CsvEditorSettingsProvider implements SearchableConfigurable {
1616

1717
public static final String CSV_EDITOR_SETTINGS_ID = "Csv.Editor.Settings";
1818

19+
public static final int MIN_TABLE_COLUMN_SIZE = 10;
20+
public static final int MAX_TABLE_COLUMN_SIZE = 10000;
21+
1922
private JCheckBox cbCaretRowShown;
2023
private JPanel myMainPanel;
2124
private JCheckBox cbUseSoftWraps;
@@ -139,8 +142,8 @@ protected void createUIComponents() {
139142
numberFormatter = new NumberFormatter(numberFormat);
140143
numberFormatter.setValueClass(Integer.class);
141144
numberFormatter.setAllowsInvalid(false);
142-
numberFormatter.setMinimum(10);
143-
numberFormatter.setMaximum(10000);
145+
numberFormatter.setMinimum(MIN_TABLE_COLUMN_SIZE);
146+
numberFormatter.setMaximum(MAX_TABLE_COLUMN_SIZE);
144147
tfDefaultColumnWidth = new JFormattedTextField(numberFormatter);
145148
}
146149
}

src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/CsvTableEditorSwing.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,9 @@ protected int getStringWidth(String text) {
488488
}
489489
JTable table = getTable();
490490
FontMetrics fontMetrics = getTable().getFontMetrics(table.getFont());
491-
return CsvHelper.getMaxTextLineLength(text, input -> (int)Math.ceil((float)(fontMetrics.stringWidth(input) + TOTAL_CELL_WIDTH_SPACING) / getZoomFactor()));
491+
return CsvHelper.getMaxTextLineLength(text, input ->
492+
(int)Math.ceil((float)(fontMetrics.stringWidth(input) + TOTAL_CELL_WIDTH_SPACING) / getZoomFactor())
493+
);
492494
}
493495

494496
public void changeFontSize(int changeAmount) {

src/main/java/net/seesharpsoft/intellij/plugins/csv/formatter/CsvFormatHelper.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ public static int charWidth(CharSequence s, boolean ambiguousWide) {
155155
return result;
156156
}
157157

158-
public static int getTextLength(String text, CodeStyleSettings codeStyleSettings) {
158+
public static int getTextLength(String textInput, CodeStyleSettings codeStyleSettings) {
159+
String text = textInput;
159160
CsvCodeStyleSettings csvCodeStyleSettings = codeStyleSettings.getCustomSettings(CsvCodeStyleSettings.class);
160161
int length = 0;
161162
if (csvCodeStyleSettings.TABULARIZE && !csvCodeStyleSettings.WHITE_SPACES_OUTSIDE_QUOTES && text.startsWith("\"")) {
@@ -164,7 +165,11 @@ public static int getTextLength(String text, CodeStyleSettings codeStyleSettings
164165
text = END_WHITE_SPACE_PATTERN.matcher(text).replaceFirst("");
165166
length += 2;
166167
}
167-
length += CsvHelper.getMaxTextLineLength(text, line -> csvCodeStyleSettings.ENABLE_WIDE_CHARACTER_DETECTION ? charWidth(line, csvCodeStyleSettings.TREAT_AMBIGUOUS_CHARACTERS_AS_WIDE) : line.length());
168+
length += CsvHelper.getMaxTextLineLength(text, input ->
169+
csvCodeStyleSettings.ENABLE_WIDE_CHARACTER_DETECTION ?
170+
charWidth(input, csvCodeStyleSettings.TREAT_AMBIGUOUS_CHARACTERS_AS_WIDE) :
171+
input.length()
172+
);
168173

169174
return length;
170175
}

0 commit comments

Comments
 (0)