Skip to content

Commit f63883a

Browse files
authored
Merge pull request #322 from SeeSharpSoft/fix_null_related_bugs
Fix null related bugs
2 parents 9b38099 + 189670b commit f63883a

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

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

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,18 @@ public void annotate(@NotNull final PsiElement element, @NotNull final Annotatio
6060
);
6161
}
6262

63-
holder.newAnnotation(CSV_COLUMN_INFO_SEVERITY, message)
63+
AnnotationBuilder annotationBuilder = holder.newAnnotation(CSV_COLUMN_INFO_SEVERITY, message)
6464
.range(element)
65-
.tooltip(tooltip)
66-
.enforcedTextAttributes(
67-
CsvEditorSettings.getInstance().getValueColoring() == CsvEditorSettings.ValueColoring.RAINBOW ?
68-
CsvColorSettings.getTextAttributesOfColumn(columnInfo.getColumnIndex(), holder.getCurrentAnnotationSession()) :
69-
null
70-
)
71-
.needsUpdateOnTyping(false)
72-
.create();
65+
.needsUpdateOnTyping(false);
66+
67+
if (CsvEditorSettings.getInstance().getValueColoring() == CsvEditorSettings.ValueColoring.RAINBOW) {
68+
annotationBuilder.enforcedTextAttributes(CsvColorSettings.getTextAttributesOfColumn(columnInfo.getColumnIndex(), holder.getCurrentAnnotationSession()));
69+
}
70+
if (tooltip != null) {
71+
annotationBuilder.tooltip(tooltip);
72+
}
73+
74+
annotationBuilder.create();
7375
}
7476
}
7577

@@ -95,8 +97,8 @@ protected boolean handleSeparatorElement(@NotNull PsiElement element, @NotNull A
9597
holder.getCurrentAnnotationSession().putUserData(TAB_SEPARATOR_HIGHLIGHT_COLOR_DETERMINED_KEY, Boolean.TRUE);
9698
}
9799
}
98-
if (textAttributes != null) {
99-
holder.newAnnotation(CSV_COLUMN_INFO_SEVERITY, showInfoBalloon(holder.getCurrentAnnotationSession()) ? "↹" : null)
100+
if (textAttributes != null && showInfoBalloon(holder.getCurrentAnnotationSession())) {
101+
holder.newAnnotation(CSV_COLUMN_INFO_SEVERITY, "↹")
100102
.range(element)
101103
.enforcedTextAttributes(textAttributes)
102104
.needsUpdateOnTyping(false)

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ protected String sanitizeFieldValue(Object value) {
163163
}
164164

165165
protected String generateCsv(Object[][] data) {
166+
CsvColumnInfoMap columnInfoMap = getColumnInfoMap();
167+
boolean newLineAtEnd = CsvEditorSettings.getInstance().isFileEndLineBreak() && (columnInfoMap == null || columnInfoMap.hasEmptyLastLine());
166168
StringBuilder result = new StringBuilder();
167169
for (int row = 0; row < data.length; ++row) {
168170
for (int column = 0; column < data[row].length; ++column) {
@@ -172,8 +174,7 @@ protected String generateCsv(Object[][] data) {
172174
result.append(this.currentSeparator.getCharacter());
173175
}
174176
}
175-
if (row < data.length - 1 ||
176-
(CsvEditorSettings.getInstance().isFileEndLineBreak() && getColumnInfoMap().hasEmptyLastLine())) {
177+
if (row < data.length - 1 || newLineAtEnd) {
177178
result.append("\n");
178179
}
179180
}

0 commit comments

Comments
 (0)