Open holgerbrandl opened 3 years ago
I am also getting the same list of exception while pasting image in markdown using this plugin in Intellij idea
I've been hacking at this for a couple of days and thought I'd share my results...
Note: I have a lot of experience with programming but not in Java and the development environment I hacked together is not without issue. Hopefully this will still be of use!
The svn4idea plugin performs the scheduleUnversionedFilesForAddition() by adding files through background tasks but the git4idea plugin does not so, as a work around, I tried replacing the following code in PasteImageFromClipboard.java:
153. usedVcs.getCheckinEnvironment().scheduleUnversionedFilesForAddition(Collections.singletonList(fileByPath));
with:
153. new Task.Backgroundable(ed.getProject(), "scheduleUnversionedFilesForAddition", false) {
154. @Override
155. public void run(@NotNull ProgressIndicator indicator) {
156. usedVcs.getCheckinEnvironment().scheduleUnversionedFilesForAddition(Collections.singletonList(fileByPath));
157. }
158. }.queue();
and added:
13. import com.intellij.openapi.progress.Task;
14. import com.intellij.openapi.progress.ProgressIndicator;
This seems to work as best as I can test it (I get an error loading IDEA but it is, I think, because of my dev env) but I can't test it properly so thought I'd share with you in the hope that you can...
I don't know if any of this helps you with fixing the issue but I hope so 'cause I really want to use the plugin!
I think that, ultimately, the problem lies in the git4idea plugin...
Best Regards, Paul T.
Thanks for the great analysis. I have also prepared an update in PasteImageFromClipboard:
if (usedVcs != null && usedVcs.getCheckinEnvironment() != null) {
ApplicationManager.getApplication().executeOnPooledThread(() -> {
usedVcs.getCheckinEnvironment().scheduleUnversionedFilesForAddition(Collections.singletonList(fileByPath));
});
}
So as you suggested putting the check into a thread seems to work around the issue. I'll keep running this patched version for a few more days before pushing out the plugin update.
So mine was definitely an over complicated way 😀
Once you push the plugin I’ll give it a spin 👍
Tested update and seems to be working 👍
This issue can be closed, @holgerbrandl