WriteCommandAction.runWriteCommandAction got stuck after the IDE was updated to 2024.2

Answered

I have an internal plugin that uses `WriteCommandAction.runWriteCommandAction` to programatically edit source files. Its basic logic looks like folllowing:

CompletionContext context = obtainEditorContext()

HttpResponse response = httpClient.post(context)

for (token in response.lines) {

LOG.info("Waiting for write token: " + token);

WriteCommandAction.runWriteCommandAction(
        project,
        (Computable<String>) () -> {
            LOG.info("Started writing token: " + token);
            int caretOffset = editor.getCaretModel().getOffset();
            editor.getDocument().insertString(caretOffset, token);
            editor.getCaretModel().moveToOffset(caretOffset + token.length());
            LOG.info("Wrote token: " + token);
            return token;
        }
);

}

The code works without any problem in IntelliJ IDEA 2024.1. However, the `WriteCommandAction.runWriteCommandAction` call always gets stuck after the IDE was updated to 2024.2. Tried to run it in debug mode where no other plugin was installed, but got no luck. The code always gets stuck after the first `LOG.info` statement, right before the `WriteCommandAction.runWriteCommandAction` call.

 

Not sure it's my local problem or a bug introduced by the new version.

0
2 comments

Hi, I don't see any issue in your code. I suggest reporting it to https://youtrack.jetbrains.com/issues/IJPL with a thread dump and possibly a minimal example project to reproduce it.

0

Thank you for your suggestion. I forgot about the thread dump tool.

 

I've created the thread dumps and created an issue there

0

Please sign in to leave a comment.