Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@

### Fixed

## 4.2.1 - May 24, 2026

### Fixed

- PluginException: Invalid PSI Element CsvFile when file is invalidated during annotation, intention actions, or inspection fixes #964
- IncorrectOperationException: parent CsvTableEditorSwing already disposed when async PsiTreeChangeListener registration completes #962
- Modified `CsvPlugin.openLink` to use `executeOnPooledThread` for setting dialogs #953
- Modified `CsvEditorSettings.java` to ensure all getter methods access the internal `OptionSet` directly instead of calling `getState()` #954
- GithubStatusCodeException: 422 Unprocessable Entity - Validation Failed during issue submission #920

## 4.2.0 - Jan 26, 2026

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

pluginName=CSV Editor
pluginId=net.seesharpsoft.intellij.plugins.csv
pluginVersion=4.2.0
pluginVersion=4.2.1

pluginSinceBuild=242

Expand Down
Empty file modified gradlew
100644 → 100755
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ protected GithubApiRequest<?> createNewIssue(String title, String content) throw
Collections.emptyList());
}

protected String searchExistingIssues(GithubApiRequestExecutor githubExecutor, String title, ProgressIndicator progressIndicator) throws IOException {
protected String searchExistingIssuesNeedle(String title) {
// Create a search needle from the title but ensure it is never null/empty to avoid GitHub 422 (Validation Failed)
String needle = title.replaceAll("\\s*(\\[.*?]|\\(.*?\\)|\\{.*?})\\s*", "");
String needle = title == null ? "" : title.replaceAll("\\s*(\\[.*?]|\\(.*?\\)|\\{.*?})\\s*", "");

// If the sanitized title becomes empty (e.g., only brackets present), fall back to the raw title
if (Strings.isEmptyOrSpaces(needle)) {
Expand All @@ -182,6 +182,12 @@ protected String searchExistingIssues(GithubApiRequestExecutor githubExecutor, S
if (Strings.isEmptyOrSpaces(needle)) {
needle = "crash";
}
return needle;
}

protected String searchExistingIssues(GithubApiRequestExecutor githubExecutor, String title, ProgressIndicator progressIndicator) throws IOException {
String needle = searchExistingIssuesNeedle(title);

GithubApiRequest<GithubResponsePage<GithubSearchedIssue>> existingIssueRequest =
GithubApiRequests.Search.Issues.get(
GithubServerPath.DEFAULT_SERVER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ public class CsvPlugin implements ProjectActivity, DumbAware {
private static void openLink(Project project, String link) {
if (project.isDisposed()) return;

ApplicationManager.getApplication().invokeLater(() ->
{
if (link.startsWith("#")) {
ShowSettingsUtil.getInstance().showSettingsDialog(project, link.substring(1));
} else {
BrowserUtil.browse(link, project);
}
});
if (link.startsWith("#")) {
ApplicationManager.getApplication().executeOnPooledThread(() ->
ShowSettingsUtil.getInstance().showSettingsDialog(project, link.substring(1))
);
} else {
ApplicationManager.getApplication().invokeLater(() ->
BrowserUtil.browse(link, project)
);
}
}

public static void doAsyncProjectMaintenance(@NotNull Project project) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public void annotate(@NotNull final PsiElement element, @NotNull final Annotatio
}

CsvFile csvFile = (CsvFile) element.getContainingFile();
if (!csvFile.isValid()) {
return;
}
if (handleSeparatorElement(element, holder, elementType, csvFile)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

public class CsvTableModelBase<T extends PsiFileHolder> implements CsvTableModel {
private final T myPsiFileHolder;
private volatile boolean myDisposed = false;

private int myCachedRowCount = -1;
private int myCachedColumnCount = -1;
Expand Down Expand Up @@ -55,7 +56,7 @@ protected void addPsiTreeChangeListener() {
.nonBlocking(this::getPsiFile)
.coalesceBy(this)
.finishOnUiThread(ModalityState.any(), pf -> {
if (pf == null) return;
if (pf == null || myDisposed) return;
PsiManager mgr = pf.getManager();
if (mgr == null) return;
mgr.addPsiTreeChangeListener(myPsiTreeChangeListener, myPsiFileHolder);
Expand All @@ -70,6 +71,7 @@ protected void addPsiTreeChangeListener() {

@Override
public void dispose() {
myDisposed = true;
CsvTableModel.super.dispose();
myPsiTreeUpdater.dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public String getFamilyName() {
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
PsiElement element = descriptor.getPsiElement();
if (element == null || !element.isValid()) return;
Document document = PsiDocumentManager.getInstance(project).getDocument(element.getContainingFile());
if (document == null) return;

Expand Down Expand Up @@ -147,6 +148,7 @@ public String getFamilyName() {
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
try {
PsiElement element = descriptor.getPsiElement();
if (element == null || !element.isValid()) return;
Document document = PsiDocumentManager.getInstance(project).getDocument(element.getContainingFile());
if (document == null) return;

Expand All @@ -168,6 +170,7 @@ public String getFamilyName() {
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
try {
PsiElement element = descriptor.getPsiElement();
if (element == null || !element.isValid()) return;
Document document = PsiDocumentManager.getInstance(project).getDocument(element.getContainingFile());
if (document == null) return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public String getFamilyName() {
public boolean isAvailable(@NotNull Project project, Editor editor, @Nullable PsiElement element) {
final PsiFile containingFile = element == null ? null : element.getContainingFile();
return containingFile != null
&& containingFile.isValid()
&& containingFile.getLanguage().isKindOf(CsvLanguage.INSTANCE)
&& PsiDocumentManager.getInstance(project).getDocument(containingFile) != null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.util.IncorrectOperationException;
import net.seesharpsoft.intellij.plugins.csv.CsvColumnInfo;
import net.seesharpsoft.intellij.plugins.csv.CsvColumnInfoMap;
Expand All @@ -18,7 +19,14 @@ public CsvShiftColumnLeftIntentionAction() {

@Override
public void invoke(@NotNull Project project, Editor editor, @NotNull final PsiElement psiElement) throws IncorrectOperationException {
CsvFile csvFile = (CsvFile) psiElement.getContainingFile();
PsiFile containingFile = psiElement.getContainingFile();
if (!(containingFile instanceof CsvFile)) {
return;
}
CsvFile csvFile = (CsvFile) containingFile;
if (!csvFile.isValid()) {
return;
}

PsiElement element = CsvHelper.getParentFieldElement(psiElement);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.util.IncorrectOperationException;
import net.seesharpsoft.intellij.plugins.csv.CsvColumnInfo;
import net.seesharpsoft.intellij.plugins.csv.CsvColumnInfoMap;
Expand All @@ -19,7 +20,14 @@ public CsvShiftColumnRightIntentionAction() {
@Override
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement psiElement)
throws IncorrectOperationException {
CsvFile csvFile = (CsvFile) psiElement.getContainingFile();
PsiFile containingFile = psiElement.getContainingFile();
if (!(containingFile instanceof CsvFile)) {
return;
}
CsvFile csvFile = (CsvFile) containingFile;
if (!csvFile.isValid()) {
return;
}

PsiElement element = CsvHelper.getParentFieldElement(psiElement);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public String getDisplay() {
public static final class OptionSet {
public String CURRENT_PLUGIN_VERSION;

public boolean CARET_ROW_SHOWN;
public boolean USE_SOFT_WRAP;
public boolean CARET_ROW_SHOWN = true;
public boolean USE_SOFT_WRAP = false;
public boolean HIGHTLIGHT_TAB_SEPARATOR = true;
public boolean SHOW_INFO_BALLOON = true;
public String TAB_HIGHLIGHT_COLOR = "-7984";
Expand All @@ -100,18 +100,6 @@ public static final class OptionSet {
private boolean isInitialized = false;

public OptionSet() {}

public void init() {
if (this.isInitialized) {
return;
}

EditorSettingsExternalizable editorSettingsExternalizable = EditorSettingsExternalizable.getInstance();
CARET_ROW_SHOWN = editorSettingsExternalizable == null ? true : editorSettingsExternalizable.isCaretRowShown();
USE_SOFT_WRAP = editorSettingsExternalizable == null ? false : editorSettingsExternalizable.isUseSoftWraps();

this.isInitialized = true;
}
}

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

@Override
public OptionSet getState() {
this.myOptions.init();
return this.myOptions;
}

Expand Down Expand Up @@ -184,7 +171,7 @@ public void setShowInfoBalloon(boolean showInfoBalloon) {
public Color getTabHighlightColor() {
String color = getState().TAB_HIGHLIGHT_COLOR;
try {
return color == null || color.isEmpty() ? null : Color.decode(getState().TAB_HIGHLIGHT_COLOR);
return color == null || color.isEmpty() ? null : Color.decode(color);
} catch (NumberFormatException exc) {
return null;
}
Expand All @@ -195,13 +182,7 @@ public void setTabHighlightColor(Color color) {
}

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

public void setEditorPrio(EditorPrio editorPrio) {
Expand All @@ -217,9 +198,8 @@ public void showTableEditorInfoPanel(boolean showInfoPanel) {
}

public int getTableEditorRowHeight() {
// ensure the current state of row height fits the boundaries (which is checked in the setTableEditorRowHeight method
setTableEditorRowHeight(getState().TABLE_EDITOR_ROW_HEIGHT);
return getState().TABLE_EDITOR_ROW_HEIGHT;
int rowHeight = getState().TABLE_EDITOR_ROW_HEIGHT;
return rowHeight > TABLE_EDITOR_ROW_HEIGHT_MAX || rowHeight < TABLE_EDITOR_ROW_HEIGHT_MIN ? TABLE_EDITOR_ROW_HEIGHT_DEFAULT : rowHeight;
}

public void setTableEditorRowHeight(int rowHeight) {
Expand Down Expand Up @@ -268,7 +248,7 @@ public void setDefaultEscapeCharacter(CsvEscapeCharacter defaultEscapeCharacter)

public CsvEscapeCharacter getDefaultEscapeCharacter() {
CsvEscapeCharacter csvValueSeparator = getState().DEFAULT_ESCAPE_CHARACTER;
return csvValueSeparator == null ? ESCAPE_CHARACTER_DEFAULT : getState().DEFAULT_ESCAPE_CHARACTER;
return csvValueSeparator == null ? ESCAPE_CHARACTER_DEFAULT : csvValueSeparator;
}

public void setDefaultValueSeparator(CsvValueSeparator defaultValueSeparator) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ public void printStackTrace(PrintWriter writer) {

private CsvGithubIssueSubmitterSubClass classUnderTest = new CsvGithubIssueSubmitterSubClass();

public void testSearchExistingIssuesNeedle() throws Exception {
assertEquals("crash", classUnderTest.searchExistingIssuesNeedle(null));
assertEquals("crash", classUnderTest.searchExistingIssuesNeedle(""));
assertEquals("crash", classUnderTest.searchExistingIssuesNeedle(" "));
assertEquals("test", classUnderTest.searchExistingIssuesNeedle("test"));
assertEquals("test", classUnderTest.searchExistingIssuesNeedle("[Automated Report] test"));
assertEquals("[Automated Report]", classUnderTest.searchExistingIssuesNeedle("[Automated Report]"));
}

public void testGetIssueTitle() {
assertEquals("[Automated Report] Test", classUnderTest.getIssueTitle(new IdeaLoggingEvent("Test", new DummyException("Test"))));
assertEquals("[Automated Report] Unhandled exception in [CoroutineName(com.intellij.openapi.fileEditor.impl.PsiAwareFileEditorManagerImpl), StandaloneCoroutine{Cancelling}, Dispatchers.Default]", classUnderTest.getIssueTitle(new IdeaLoggingEvent("Test", new DummyException("Unhandled exception in [CoroutineName(com.intellij.openapi.fileEditor.impl.PsiAwareFileEditorManagerImpl), StandaloneCoroutine{Cancelling}@5cfe3e69, Dispatchers.Default]"))));
Expand Down
Loading
Loading