-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix: focus correct workspace folder
- Loading branch information
1 parent
07f75c4
commit df3fa6c
Showing
11 changed files
with
164 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
metals/src/main/scala/scala/meta/internal/metals/BspStatus.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package scala.meta.internal.metals | ||
|
||
import java.util.Collections | ||
import java.util.concurrent.atomic.AtomicReference | ||
|
||
import scala.meta.internal.metals.clients.language.MetalsLanguageClient | ||
import scala.meta.internal.metals.clients.language.MetalsStatusParams | ||
import scala.meta.io.AbsolutePath | ||
|
||
class BspStatus(client: MetalsLanguageClient, isBspStatusProvider: Boolean) { | ||
val focusedFolder: AtomicReference[Option[AbsolutePath]] = | ||
new AtomicReference(None) | ||
val messages: java.util.Map[AbsolutePath, MetalsStatusParams] = | ||
Collections.synchronizedMap( | ||
new java.util.HashMap[AbsolutePath, MetalsStatusParams] | ||
) | ||
|
||
def status(folder: AbsolutePath, params: MetalsStatusParams): Unit = { | ||
messages.put(folder, params) | ||
if (focusedFolder.get().isEmpty || focusedFolder.get().contains(folder)) { | ||
client.metalsStatus(params) | ||
} | ||
} | ||
|
||
def focus(folder: AbsolutePath): Unit = { | ||
if (isBspStatusProvider) { | ||
val prev = focusedFolder.getAndSet(Some(folder)) | ||
if (!prev.contains(folder)) { | ||
client.metalsStatus( | ||
messages.getOrDefault(folder, ConnectionBspStatus.disconnectedParams) | ||
) | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.