@@ -2,6 +2,8 @@ package com.emberjs.glint
22
33import com.dmarcotte.handlebars.file.HbFileType
44import com.emberjs.gts.GtsFileType
5+ import com.emberjs.utils.emberRoot
6+ import com.emberjs.utils.parentEmberModule
57import com.emberjs.utils.parentModule
68import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer
79import com.intellij.execution.configurations.GeneralCommandLine
@@ -16,10 +18,9 @@ import com.intellij.openapi.Disposable
1618import com.intellij.openapi.application.ApplicationManager
1719import com.intellij.openapi.components.Service
1820import com.intellij.openapi.project.Project
19- import com.intellij.openapi.project.guessProjectDir
2021import com.intellij.openapi.vfs.VfsUtilCore
2122import com.intellij.openapi.vfs.VirtualFile
22- import com.intellij.openapi.vfs.findPsiFile
23+ import com.intellij.openapi.vfs.isFile
2324import com.intellij.platform.lsp.api.LspServerDescriptor
2425import com.intellij.platform.lsp.api.LspServerManager
2526import com.intellij.platform.lsp.api.LspServerSupportProvider
@@ -51,7 +52,7 @@ class GlintLspServerDescriptor(private val myProject: Project) : LspServerDescri
5152 val lspServerManager = LspServerManager .getInstance(project)
5253 var isWsl = false
5354 var wslDistro = " "
54- var lastDir = project.guessProjectDir()
55+ var lastDir: VirtualFile ? = null
5556
5657 public val server
5758 get() =
@@ -86,13 +87,20 @@ class GlintLspServerDescriptor(private val myProject: Project) : LspServerDescri
8687 }
8788
8889 fun isAvailable (vfile : VirtualFile ): Boolean {
89- if (vfile.parentModule != null && isAvailableFromDir(vfile.parentModule!! )) {
90- return true
91- }
92- if (project.guessProjectDir() != null && isAvailableFromDir(project.guessProjectDir()!! )) {
93- return true
90+ var f: VirtualFile ? = vfile
91+ while (true ) {
92+ if (f?.isFile == true ) {
93+ f = f.parent
94+ }
95+ if (f?.path?.contains(" node_modules" ) == true ) {
96+ continue
97+ }
98+ if (f != null && isAvailableFromDir(f)) {
99+ return true
100+ }
101+ f = f?.parentEmberModule
102+ if (f == null ) return false
94103 }
95- return false
96104 }
97105
98106 fun ensureStarted (vfile : VirtualFile ) {
0 commit comments