wendrowycz / go-imports-tidy

Apache License 2.0
7 stars 3 forks source link

Multiple projects are brake "local namespace" setting #4

Closed EldarKurbanov closed 2 years ago

EldarKurbanov commented 2 years ago

Case:

  1. Open two projects in GoLand on different windows with "local namespace" setting.
  2. The last opened project will sort imports correctly;
  3. The first opened project will not sort imports correctly until we close the last opened project in GoLand.

Notes: Checkbox "Format imports on save" is on

Information about my GoLand:

GoLand 2022.2.4
Build #GO-222.4345.24, built on October 11, 2022
Licensed to Eldar Kurbanov
Subscription is active until March 12, 2023.
For educational use only.
Runtime version: 17.0.4.1+7-b469.62 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.19.15-201.fc36.x86_64
GC: G1 Young Generation, G1 Old Generation
Memory: 1024M
Cores: 8
Registry:
    suggest.all.run.configurations.from.context=true
    ide.completion.variant.limit=500

Non-Bundled Plugins:
    ro.florinpatan.gopher (2021.1)
    me.serce.solidity (2.3.10)
    eu.oakroot.go-imports-tidy (1.0.7)
    dk.cego.gitlab_ci_local_plugin (0.0.4)
    com.tabnine.TabNine (0.7.26)
    com.planetexpress.go_struct_tag_generator (1.2.8)
    com.intellij.ideolog (203.0.30.0)
    com.github.weisj.darkmode (1.7.1-2022.2)
    uk.co.ben-gibson.remote.repository.mapper (4.2.3)
    com.ypwang.plugin.go-linter (1.6.1)
    de.sist.gitlab (2.13.0)
    com.majera.intellij.codereview.gitlab (2022.4.4.221)
    com.github.shiraji.findpullrequest (1.7.2)
    com.codestream.jetbrains-codestream (14.3.0+265)
    com.almightyalpaca.intellij.plugins.discord (1.10.0)
    app.teamhub (15.0.11)

Current Desktop: GNOME
wendrowycz commented 2 years ago

Formatting is triggered when the save document event is triggered. This is done automatically but can be done manually (ctrl+s). After recreating the above-mentioned situation and saving the document manually, the formatting was carried out correctly. I also noticed that after some time the formatting gets done correctly. I also checked on a clean GoLand installation (only default plugins) whether there would be a delay in the autosave of the document. This can be done by formatting the code that is run when the document is saved. In this case, the formatting took place only after a manual save. I conclude that this is an environmental affliction (Linux + GNOME). I work on macOS Monterey on a daily basis with many windows open at the same time and a similar situation never appeared. Please try save the file manually and check if the formatting is correct after that.

EldarKurbanov commented 2 years ago

I unchecked "Format imports on save" and tried to use "GO import tidy" button in context menu manually and it looks like it works correctly with two opened projects

bargrz commented 2 years ago

When you set "Format imports on save" and you use ctrl+s save shortcut this also should work in current window with multi projects. In other words - for this option save event must be called: manually or automatically. If this not happen (in some case) then formatting imports will not run. If you spot any errors in stored log pleas attache here.

EldarKurbanov commented 2 years ago

Sort imports happens on file save, but not correctly (like in original issue message). But if I use button in the context menu, it works correctly

EldarKurbanov commented 2 years ago

In my logs I don't see any messages or errors from tidy plugin. I searched by word "tidy" in idea.log

bargrz commented 2 years ago

Can you give an example before sorting and after sorting in the described case (format on save)? I would like to see the anomaly you write about. Maybe I can reproduce it.

EldarKurbanov commented 2 years ago

I recorded a video: https://www.youtube.com/watch?v=rKHQFNyYPYc

In this video I show:

wendrowycz commented 2 years ago

Thank you. Ill try to reproduce similar situation and fix it

wendrowycz commented 2 years ago

SOLVED: v1.0.8

@EldarKurbanov You can download from GitHub or wait for JetBrains approval to download from official marketplace.

EldarKurbanov commented 2 years ago

Thank you! I will wait :+1: