refactor: improve folder suggestions update strategy

This commit is contained in:
Carl-Robert Linnupuu 2024-07-26 13:49:37 +03:00
parent e0dd612a70
commit 96ac29640d
2 changed files with 6 additions and 16 deletions

View file

@ -107,7 +107,10 @@ class FolderSuggestionActionStrategy : SuggestionUpdateStrategy {
.filter { path ->
val file = virtualFileManager.findFileByNioPath(path)
val isProjectFile =
file != null && runReadAction { projectFileIndex.isInContent(file) }
file != null && runReadAction {
projectFileIndex.isInSourceContent(file)
|| projectFileIndex.isInTestSourceContent(file)
}
path.isDirectory() && !path.startsWith(".") && isProjectFile
}
.forEach { folder ->
@ -147,21 +150,6 @@ class PersonaSuggestionActionStrategy : SuggestionUpdateStrategy {
}
}
class CreatePersonaActionStrategy : SuggestionUpdateStrategy {
override fun populateSuggestions(
project: Project,
listModel: DefaultListModel<SuggestionItem>,
) {
}
override fun updateSuggestions(
project: Project,
listModel: DefaultListModel<SuggestionItem>,
searchText: String,
) {
}
}
class DefaultSuggestionActionStrategy : SuggestionUpdateStrategy {
override fun populateSuggestions(
project: Project,

View file

@ -114,6 +114,8 @@ class SuggestionsPopupManager(
fun updateSuggestions(searchText: String) {
currentActionStrategy.updateSuggestions(project, listModel, searchText)
list.revalidate()
list.repaint()
}
fun reset(clearPrevious: Boolean = true) {