Repository: hannah-sten/texify-idea
Issue: Package included from relative path doesn't get parsed properly

#### Type of JetBrains IDE (IntelliJ, PyCharm, etc.) and version
PyCharm 2020.2 (Community Edition)
Build #PC-202.6397.98, built on July 27, 2020
Runtime version: 11.0.7+10-b944.20 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 2004M
Cores: 4
Non-Bundled Plugins: nl.rubensten.texifyidea, com.kite.intellij


#### TeXiFy version

0.6.10


#### What I did (steps to reproduce)
I have a package `Bar.sty` that I use for multiple documents. Thus, it is stored in a path relative to all of my other LaTeX projects.
I just include this package normally, using `\\usepackage` and the relative path. But TeXiFy then shows many supposed errors, indicating it does not read the contents of my package.


#### Minimal example to reproduce the problem
Here's the package file `Bar.sty`, in Folder ../Foo:
```latex
\\ProvidesPackage{../Foo/Bar}
\\usepackage[utf8]{inputenc}
\\usepackage[T1]{fontenc}
```

Here's the `main.tex` document:
```latex
\\documentclass{article}
\\usepackage{../Foo/Bar}
\\begin{document}
Here come some german umlaut's: Ä Ö Ü
\\end{document}
```

#### Expected behavior
TeXiFy parses the package and thus knows about the encoding, in effect not highlighting any ASCII characters as unsupported.


#### Actual behavior
TeXiFy does not know about the encoding, even though the `\\usepackage` directive in the main file seems fine for TeXiFy.
HOWEVER, if I place the `Bar.sty` package file in the main project directory (where my main.tex resides), everything DOES work as intended -- no erros.

Thus, there seems to be some problem regarding relative paths.

Changed files:
src/nl/hannahsten/texifyidea/util/files/ReferencedFileSetCache.kt, test/nl/hannahsten/texifyidea/reference/LatexLabelCompletionTest.kt

diff --git a/src/nl/hannahsten/texifyidea/util/files/ReferencedFileSetCache.kt b/src/nl/hannahsten/texifyidea/util/files/ReferencedFileSetCache.kt
index 3e31f4c81..2f75d0a02 100644
--- a/src/nl/hannahsten/texifyidea/util/files/ReferencedFileSetCache.kt
+++ b/src/nl/hannahsten/texifyidea/util/files/ReferencedFileSetCache.kt
@@ -3,8 +3,7 @@ package nl.hannahsten.texifyidea.util.files
 import com.intellij.openapi.application.runReadAction
 import com.intellij.openapi.vfs.VirtualFile
 import com.intellij.psi.PsiFile
-import kotlinx.coroutines.GlobalScope
-import kotlinx.coroutines.launch
+import kotlinx.coroutines.runBlocking
 import kotlinx.coroutines.sync.Mutex
 import kotlinx.coroutines.sync.withLock
 import nl.hannahsten.texifyidea.file.listeners.VfsChangeListener
@@ -61,7 +60,7 @@ class ReferencedFileSetCache {
             // getOrPut cannot be used because it will still execute the defaultValue function even if the key is already in the map (see its javadoc)
             // Wrapping the code with synchronized (myLock) { ... } also didn't work
             // Hence we use a mutex to make sure the expensive findReferencedFileSet function is only executed when needed
-            GlobalScope.launch {
+            runBlocking {
                 mutex.withLock {
                     if (!fileSetCache.containsKey(file.virtualFile) || numberOfIncludesChanged) {
                         runReadAction {
diff --git a/test/nl/hannahsten/texifyidea/reference/LatexLabelCompletionTest.kt b/test/nl/hannahsten/texifyidea/reference/LatexLabelCompletionTest.kt
index 864ba71fa..c25d9b81d 100644
--- a/test/nl/hannahsten/texifyidea/reference/LatexLabelCompletionTest.kt
+++ b/test/nl/hannahsten/texifyidea/reference/LatexLabelCompletionTest.kt
@@ -1,11 +1,11 @@
 package nl.hannahsten.texifyidea.reference
 
 import com.intellij.codeInsight.completion.CompletionType
-import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase
+import com.intellij.testFramework.fixtures.BasePlatformTestCase
 import nl.hannahsten.texifyidea.file.LatexFileType
 import org.junit.Test
 
-class LatexLabelCompletionTest : LightJavaCodeInsightFixtureTestCase() {
+class LatexLabelCompletionTest : BasePlatformTestCase() {
     override fun getTestDataPath(): String {
         return "test/resources/completion/cite"
     }
@@ -56,23 +56,16 @@ class LatexLabelCompletionTest : LightJavaCodeInsightFixtureTestCase() {
     private fun runCompletion() {
         myFixture.configureByFiles("${getTestName(false)}.tex", "bibtex.bib")
 
-        // Seems like this also helps making sure the file is indexed before using autocompletion
-        assertTrue(myFixture.findAllGutters().size > 0)
-
         // when
         myFixture.complete(CompletionType.BASIC)
     }
 
-//    @Test
-//    fun testCompleteBibtexWithCorrectCase() {
-    // Using the following failed sometimes
-//        myFixture.testCompletion("${testName}_before.tex", "${testName}_after.tex", "$testName.bib")
-//        val testName = getTestName(false)
-//        myFixture.configureByFiles("${testName}_before.tex", "$testName.bib")
-//        myFixture.complete(CompletionType.BASIC)
-//        myFixture.findAllGutters() // This seems to allow the completion to complete, and to make the test pass
-//        myFixture.checkResultByFile("${testName}_after.tex")
-//    }
+    @Test
+    fun testCompleteBibtexWithCorrectCase() {
+        // Using the following failed sometimes
+        val testName = getTestName(false)
+        myFixture.testCompletion("${testName}_before.tex", "${testName}_after.tex", "$testName.bib")
+    }
 
     @Test
     fun testLabelReferenceCompletion() {