mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[grazie] Fix highlighting issues downloading missing languages
Merge-request: IJ-MR-173274 Merged-by: Ilia Permiashkin <ilia.permiashkin@jetbrains.com> GitOrigin-RevId: c656c911c04e42ab2a22ce6bd1c964c4152be689
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ee8239ff09
commit
2d12604281
@@ -12,8 +12,7 @@ import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.extensions.PluginId
|
||||
import com.intellij.openapi.project.ProjectManager
|
||||
import com.intellij.spellchecker.SpellCheckerManager
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.async
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
@ApiStatus.Internal
|
||||
@@ -36,17 +35,15 @@ object GraziePlugin {
|
||||
return
|
||||
}
|
||||
|
||||
val newLanguages = newState.enabledLanguages.filterHunspell()
|
||||
val prevLanguages = prevState.enabledLanguages.filterHunspell()
|
||||
if (prevLanguages == newLanguages) return
|
||||
GrazieScope.coroutineScope().async {
|
||||
val newLanguages = newState.enabledLanguages.filterHunspell()
|
||||
val prevLanguages = prevState.enabledLanguages.filterHunspell()
|
||||
|
||||
GrazieScope.coroutineScope().launch(Dispatchers.IO) {
|
||||
ProjectManager.getInstance().openProjects.forEach { project ->
|
||||
val manager = SpellCheckerManager.getInstance(project)
|
||||
|
||||
(newLanguages - prevLanguages).forEach { manager.spellChecker!!.addDictionary(it.dictionary!!) }
|
||||
(prevLanguages - newLanguages).forEach { prev ->
|
||||
val dicPath = getLangDynamicFolder(prev).resolve(prev.hunspellRemote!!.file).toString()
|
||||
newLanguages.forEach { language -> manager.spellChecker!!.addDictionary(language.dictionary!!) }
|
||||
(prevLanguages - newLanguages).forEach { language ->
|
||||
val dicPath = getLangDynamicFolder(language).resolve(language.hunspellRemote!!.file).toString()
|
||||
manager.removeDictionary(dicPath)
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ import com.intellij.spellchecker.grazie.dictionary.ExtendedWordListWithFrequency
|
||||
import com.intellij.spellchecker.grazie.dictionary.WordListAdapter
|
||||
import com.intellij.spellchecker.grazie.ranker.DiacriticSuggestionRanker
|
||||
import com.intellij.spellchecker.hunspell.HunspellDictionary
|
||||
import com.intellij.spellchecker.inspections.IdentifierSplitter
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.cancel
|
||||
@@ -145,7 +144,7 @@ class GrazieSpellCheckerEngine(
|
||||
}
|
||||
|
||||
override fun addDictionary(dictionary: Dictionary) {
|
||||
adapter.addDictionary(dictionary)
|
||||
if (!isDictionaryLoad(dictionary.name)) adapter.addDictionary(dictionary)
|
||||
}
|
||||
|
||||
override fun addModifiableDictionary(dictionary: EditableDictionary) {
|
||||
|
||||
Reference in New Issue
Block a user