anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: hannah-sten/texify-idea
Issue: \\citet triggers inspection

For example, consider the following sentence in a LaTeX document:

> Readers interested in these aspects are referred to \\citet{Duda2001}.

`\\citet` inserts a citation formatted to be part of the sentence, either "Duda et al. (2001)" or "Duda et al. [1]", depending on the citation style. Therefore, it does not need (and should not have) a non-breaking space before.

However, it triggers the "Reference without a non-breaking space" inspection. This inspection should only apply to `\\cite` and `\\citep` commands, not to `\\citet`.


Changed files:
src/nl/rubensten/texifyidea/inspections/latex/LatexNonBreakingSpaceInspection.kt

diff --git a/src/nl/rubensten/texifyidea/inspections/latex/LatexNonBreakingSpaceInspection.kt b/src/nl/rubensten/texifyidea/inspections/latex/LatexNonBreakingSpaceInspection.kt
index 6163103c9..7452be354 100644
--- a/src/nl/rubensten/texifyidea/inspections/latex/LatexNonBreakingSpaceInspection.kt
+++ b/src/nl/rubensten/texifyidea/inspections/latex/LatexNonBreakingSpaceInspection.kt
@@ -25,9 +25,17 @@ import nl.rubensten.texifyidea.util.parentOfType
  */
 open class LatexNonBreakingSpaceInspection : TexifyInspectionBase() {
 
+    companion object {
+
+        /**
+         * All commands that should not have a forced breaking space.
+         */
+        val IGNORED_COMMANDS = setOf("\\\\citet", "\\\\citet*", "\\\\Citet", "\\\\Citet*")
+    }
+
     override fun getInspectionGroup() = InsightGroup.LATEX
 
-    override fun getDisplayName() = "Start sentences on a new line"
+    override fun getDisplayName() = "Non-breaking spaces before references"
 
     override fun getInspectionId() = "NonBreakingSpace"
 
@@ -36,9 +44,11 @@ open class LatexNonBreakingSpaceInspection : TexifyInspectionBase() {
 
         val commands = LatexCommandsIndex.getItems(file)
         for (command in commands) {
-            if (!Magic.Command.reference.contains(command.name)) {
-                continue
-            }
+            // Only target references.
+            if (!Magic.Command.reference.contains(command.name)) continue
+
+            // Don't consider certain commands.
+            if (command.name in IGNORED_COMMANDS) continue
 
             // Get the NORMAL_TEXT in front of the command.
             val sibling = command.parentOfType(LatexContent::class)?.prevSibling ?: continue
Repository: hannah-sten/texify-idea
Issue: Word count does not ignore non-source files.

#### Type of JetBrains IDE (IntelliJ, PyCharm, etc.) and version
IntelliJ IDEA Ultimate 2019.1

#### TeXiFy IDEA version
b0.6.4

#### What I did (steps to reproduce)
Project with `main.tex` and included `.sty` style file. Ran word count, got word count from both files.

#### Expected behavior
Word count only counting words in files of type `LatexFileType`.

#### Actual behavior
Got word count of `.tex` file and `.sty` file

Changed files:
src/nl/rubensten/texifyidea/action/analysis/WordCountAction.kt

diff --git a/src/nl/rubensten/texifyidea/action/analysis/WordCountAction.kt b/src/nl/rubensten/texifyidea/action/analysis/WordCountAction.kt
index c123c0fbe..447d5004b 100644
--- a/src/nl/rubensten/texifyidea/action/analysis/WordCountAction.kt
+++ b/src/nl/rubensten/texifyidea/action/analysis/WordCountAction.kt
@@ -33,7 +33,7 @@ open class WordCountAction : AnAction(
                 "\\\\usepackage", "\\\\documentclass", "\\\\label", "\\\\linespread", "\\\\ref", "\\\\cite", "\\\\eqref", "\\\\nameref",
                 "\\\\autoref", "\\\\fullref", "\\\\pageref", "\\\\newcounter", "\\\\newcommand", "\\\\renewcommand",
                 "\\\\setcounter", "\\\\resizebox", "\\\\includegraphics", "\\\\include", "\\\\input", "\\\\refstepcounter",
-                "\\\\counterwithins", "\\\\RequirePackage"
+                "\\\\counterwithins", "\\\\RequirePackage", "\\\\bibliography", "\\\\bibliographystyle"
         )
 
         /**
@@ -103,6 +103,7 @@ open class WordCountAction : AnAction(
      */
     private fun countWords(baseFile: PsiFile): Pair<Int, Int> {
         val fileSet = baseFile.referencedFileSet()
+                .filter { it.name.endsWith(".tex", ignoreCase = true) }
         val allNormalText = fileSet.flatMap { it.childrenOfType(LatexNormalText::class) }
 
         val bibliographies = baseFile.childrenOfType(LatexEnvironment::class)
Repository: hannah-sten/texify-idea
Issue: Inspector thinks semicolon ends a sentence

#### Type of JetBrains IDE (IntelliJ, PyCharm, etc.) and version
PhpStorm 2022.2.4

#### Operating System 
Ubuntu 20.4.5 LTS

#### TeXiFy IDEA version
0.7.23

#### What I did (steps to reproduce)
Use Settings to ensure the "Start sentences on a new line" inspection is turned on.
Create a document with the sentence "This is an example sentence; it is a silly one."

#### Minimal example to reproduce the problem

```latex
\\documentclass{article}
\\begin{document}
This is an example sentence; it is a silly one.   
\\end{document}
```
#### Expected behavior
No problems flagged by the inspector.

#### Actual behavior
Inspector flags a "Start sentences on a new line" problem. It wants "it is a silly one" on a new line.


#### (if applicable) The full stacktrace of the exception thrown
N/A

Changed files:
src/nl/hannahsten/texifyidea/util/magic/PatternMagic.kt

diff --git a/src/nl/hannahsten/texifyidea/util/magic/PatternMagic.kt b/src/nl/hannahsten/texifyidea/util/magic/PatternMagic.kt
index 58f4156e2..a6b2de624 100644
--- a/src/nl/hannahsten/texifyidea/util/magic/PatternMagic.kt
+++ b/src/nl/hannahsten/texifyidea/util/magic/PatternMagic.kt
@@ -26,9 +26,10 @@ object PatternMagic {
      * Matches the end of a sentence.
      *
      * Includes `[^.][^.]` because of abbreviations (at least in Dutch) like `s.v.p.`
+     * An English semicolon is not a sentence end, but a greek question mark is.
      */
     const val sentenceEndPrefix = "[^.A-Z][^.A-Z]"
-    val sentenceEnd = RegexPattern.compile("($sentenceEndPrefix[.?!;;] +[^%\\\\s])|(^\\\\. )")!!
+    val sentenceEnd = RegexPattern.compile("($sentenceEndPrefix[.?!;] +[^%\\\\s])|(^\\\\. )")!!
 
     /**
      * Matches all interpunction that marks the end of a sentence.
Repository: hannah-sten/texify-idea
Issue: Missing label inspection triggered after moving section with subsection to separate file.

Using the "move section contents to separate file" intention on `\\section{One}` in

```
\\section{One}\\label{sec:one}
\\subsection{Two}\\label{subsec:two}
```

creates (correctly) the new file and inputs it, resulting in

```
\\section{One}\\label{sec:one}
\\input{one}
```

but the "missing label" inspection is incorrectly triggered on `\\input{one}`. It disappears when typing directly after `\\input{one}`.

#### Type of JetBrains IDE (IntelliJ, PyCharm, etc.) and version
IntelliJ 2019.2.4

#### TeXiFy IDEA version
0.7-alpha.45

Changed files:
src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt

diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt
index 91b4a30b9..df2d31915 100644
--- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt
+++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexMissingLabelInspection.kt
@@ -38,7 +38,9 @@ open class LatexMissingLabelInspection : TexifyInspectionBase() {
 
         val commands = file.commandsInFile()
         for (command in commands) {
-            if (!Magic.Command.labeled.containsKey(command.name) || command.name == "\\\\item" || command.hasStar()) {
+            // It is important to use commandToken.text instead of command.name,
+            // because command.name may still be an old indexed and possibly incorrect value
+            if (!Magic.Command.labeled.containsKey(command.commandToken.text) || command.commandToken.text == "\\\\item" || command.hasStar()) {
                 continue
             }
Repository: hannah-sten/texify-idea
Issue: Equation preview use amsthm.sty which is part of amscls package.

Environment: Windows10, PyCharm, TeXiFy-IDEA 0.7.8


Problem: I verified that the problem occurs when the amscls package is not installed on your system. No detailed error message is printed. Equation preview only shows "pdflatex exited with 1". 

Solution: Install amscls package.

Changed files:
src/nl/hannahsten/texifyidea/ui/PreviewFormUpdater.kt, src/nl/hannahsten/texifyidea/util/SystemEnvironment.kt

diff --git a/src/nl/hannahsten/texifyidea/ui/PreviewFormUpdater.kt b/src/nl/hannahsten/texifyidea/ui/PreviewFormUpdater.kt
index 170300b6f..9dbfc80b9 100644
--- a/src/nl/hannahsten/texifyidea/ui/PreviewFormUpdater.kt
+++ b/src/nl/hannahsten/texifyidea/ui/PreviewFormUpdater.kt
@@ -170,7 +170,7 @@ $previewCode
         val result = runCommandWithExitCode(command, *args, workingDirectory = workDirectory, timeout = waitTime)
 
         if (result.second != 0) {
-            previewForm.setLatexErrorMessage("$command exited with ${result.second}\\n${result.first}")
+            previewForm.setLatexErrorMessage("$command exited with ${result.second}\\n${result.first ?: ""}")
             return null
         }
 
diff --git a/src/nl/hannahsten/texifyidea/util/SystemEnvironment.kt b/src/nl/hannahsten/texifyidea/util/SystemEnvironment.kt
index 7903df6fc..5748c4612 100644
--- a/src/nl/hannahsten/texifyidea/util/SystemEnvironment.kt
+++ b/src/nl/hannahsten/texifyidea/util/SystemEnvironment.kt
@@ -59,9 +59,10 @@ fun runCommandWithExitCode(vararg commands: String, workingDirectory: File? = nu
             return Pair(output, proc.exitValue())
         }
         else {
+            val output = proc.inputStream.bufferedReader().readText().trim() + proc.errorStream.bufferedReader().readText().trim()
             proc.destroy()
             proc.waitFor()
-            Pair(null, proc.exitValue())
+            Pair(output, proc.exitValue())
         }
     }
     catch (e: IOException) {
Repository: hannah-sten/texify-idea
Issue: Laggy/Slow IDE - Both Intellij and PyCharm work slow with TeXiFy

#### Type of JetBrains IDE (IntelliJ, PyCharm, etc.) and version
Intellij 2021.2.3. and PyCharm 2021.2.2.

#### Operating System 
Windows 10

#### TeXiFy IDEA version
0.7.11

#### What I did 
Whenever I try to type something in the IDE it slows down. Last time it did so, I updated Intellij and it started working again but once I opened it back up it, it started lagging again. I have no new updates and the not stable versions of the IDE's won't work properly with TeXiFy either.

The problem occurs as soon as I start typing and I tried not having packages on as well.

Changed files:
src/nl/hannahsten/texifyidea/util/files/LatexPackageLocationCache.kt

diff --git a/src/nl/hannahsten/texifyidea/util/files/LatexPackageLocationCache.kt b/src/nl/hannahsten/texifyidea/util/files/LatexPackageLocationCache.kt
index 4dc49f77e..1bd8834f7 100644
--- a/src/nl/hannahsten/texifyidea/util/files/LatexPackageLocationCache.kt
+++ b/src/nl/hannahsten/texifyidea/util/files/LatexPackageLocationCache.kt
@@ -33,8 +33,8 @@ object LatexPackageLocationCache {
             else {
                 runKpsewhich(name, project)
             }
-            if (path?.isBlank() == true) return null
             cache[name] = path
+            if (path?.isBlank() == true) return null
             return path
         }
Repository: hannah-sten/texify-idea
Issue: Autocompletion for custom commands with multiple required arguments only suggests one

#### Type of JetBrains IDE (IntelliJ, PyCharm, etc.) and version
PyCharm Build #PY-212.4746.96, built on July 27, 2021

#### Operating System 
Win 10


#### TeXiFy IDEA version
0.7.11

#### What I did (steps to reproduce)
Define a command with more than one required arguments, then try to use auto-completion.

#### Minimal example to reproduce the problem
<!-- Make sure you have read and understood how to create a minimal example: https://tex.meta.stackexchange.com/questions/228/ive-just-been-asked-to-write-a-minimal-example-what-is-that -->

```latex
\\documentclass{article}

\\newcommand{\\test}[3][1]{#1#2#3}
\\newcommand{\\foo}[2]{#1#2}

% Document
\\begin{document}
    \\test
    \\foo
\\end{document}
```

#### Expected behavior
Auto completion will only suggest all required arguments, e.g. `\\test[]{param1}{param2}`.


#### Actual behavior
Auto completion will only suggest one required argument, i.e. `\\test[]{param}`.

Thanks for the awesome plugin btw :)

Changed files:
src/nl/hannahsten/texifyidea/completion/LatexCommandsAndEnvironmentsCompletionProvider.kt

diff --git a/src/nl/hannahsten/texifyidea/completion/LatexCommandsAndEnvironmentsCompletionProvider.kt b/src/nl/hannahsten/texifyidea/completion/LatexCommandsAndEnvironmentsCompletionProvider.kt
index 210d43499..9d10d9b0f 100644
--- a/src/nl/hannahsten/texifyidea/completion/LatexCommandsAndEnvironmentsCompletionProvider.kt
+++ b/src/nl/hannahsten/texifyidea/completion/LatexCommandsAndEnvironmentsCompletionProvider.kt
@@ -1,6 +1,5 @@
 package nl.hannahsten.texifyidea.completion
 
-import com.google.common.base.Strings
 import com.intellij.codeInsight.completion.CompletionParameters
 import com.intellij.codeInsight.completion.CompletionProvider
 import com.intellij.codeInsight.completion.CompletionResultSet
@@ -258,7 +257,12 @@ class LatexCommandsAndEnvironmentsCompletionProvider internal constructor(privat
                     catch (ignore: NumberFormatException) {
                     }
                 }
-                (if (optional.size == 2) "[args]" else "") + Strings.repeat("{param}", requiredParameterCount)
+
+                (if (optional.size == 2) "[args]" else "") +
+                        if (requiredParameterCount == 1) "{param}"
+                        // Number the required parameters so a toSet call won't merge them. This way the
+                        // user can keep them apart as well.
+                        else (1..requiredParameterCount).joinToString("") { "{param$it}" }
             }
 
             "\\\\DeclarePairedDelimiter" -> "{param}"
Repository: hannah-sten/texify-idea
Issue: Run Configuration template overwrites directory paths upon saving

#### Type of JetBrains IDE (IntelliJ, PyCharm, etc.) and version
PyCharm 2021.2.2

#### Operating System 
Windows 10


#### TeXiFy IDEA version
0.7.11

#### What I did (steps to reproduce)
Edited the LaTeX  Run configuration template directories

#### Minimal example to reproduce the problem
Open "Run -> Edit Configurations..."
Click "Edit Configuration templates..."
Open LaTeX
Edit the directory for output files
Click Apply
#### Expected behavior
The directories for output files and auxiliary files are saved indepedently

#### Actual behavior
The directory for auxiliary files is always overwritten to be the same as for output files



Changed files:
src/nl/hannahsten/texifyidea/run/latex/ui/LatexSettingsEditor.kt

diff --git a/src/nl/hannahsten/texifyidea/run/latex/ui/LatexSettingsEditor.kt b/src/nl/hannahsten/texifyidea/run/latex/ui/LatexSettingsEditor.kt
index f2cdcf9b5..dd68b33d7 100644
--- a/src/nl/hannahsten/texifyidea/run/latex/ui/LatexSettingsEditor.kt
+++ b/src/nl/hannahsten/texifyidea/run/latex/ui/LatexSettingsEditor.kt
@@ -101,7 +101,7 @@ class LatexSettingsEditor(private var project: Project?) : SettingsEditor<LatexR
 
         if (auxilPath != null) {
             val auxilPathTextField = auxilPath!!.component as TextFieldWithBrowseButton
-            auxilPathTextField.text = runConfiguration.auxilPath.virtualFile?.path ?: runConfiguration.outputPath.pathString
+            auxilPathTextField.text = runConfiguration.auxilPath.virtualFile?.path ?: runConfiguration.auxilPath.pathString
         }
 
         val outputPathTextField = outputPath.component as TextFieldWithBrowseButton
Repository: hannah-sten/texify-idea
Issue: Can't open documentation

According to [TeXiFy documentation](https://github.com/Hannah-Sten/TeXiFy-IDEA/wiki/LaTeX-documentation), if I have the cursor on an `\\usepackage{somepackage}` command, I should be able to see its PDF documentation by pressing `Ctrl-Q`.

This is not working for me. I do have `texdoc` installed and running (it works fine in the terminal).

I'm missing something or this can be a bug?

**Edit**: 
The links to the PDF files appears only for `\\begin{document}` and nowhere else.

- Debian 11
- IntelliJ IDEA 2022.1 (Community Edition)
   - Build #IC-221.5080.210, built on April 12, 2022
   - Runtime version: 11.0.14.1+1-b2043.25 amd64
   - VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
- TeXiFy 0.7.16 
- Texdoc 3.2.2 (2020-09-16)
- texlive-full 2020.20210202-3 (`apt` from Debian repositories)


Changed files:
src/nl/hannahsten/texifyidea/lang/commands/LatexCommand.kt

diff --git a/src/nl/hannahsten/texifyidea/lang/commands/LatexCommand.kt b/src/nl/hannahsten/texifyidea/lang/commands/LatexCommand.kt
index 9ccc5b9dd..a79531c4d 100644
--- a/src/nl/hannahsten/texifyidea/lang/commands/LatexCommand.kt
+++ b/src/nl/hannahsten/texifyidea/lang/commands/LatexCommand.kt
@@ -45,9 +45,11 @@ interface LatexCommand : Described, Dependend {
         fun lookupInIndex(cmdWithoutSlash: String, project: Project): Set<LatexCommand> {
             // Don't try to access index when in dumb mode
             if (DumbService.isDumb(project)) return emptySet()
-
-            val cmds = mutableSetOf<LatexCommand>()
             val cmdWithSlash = "\\\\$cmdWithoutSlash"
+
+            // Make sure to look up the hardcoded commands, to have something in case nothing is found in the index
+            val cmds = lookup(cmdWithSlash)?.toMutableSet() ?: mutableSetOf()
+
             // Look up in index
             FileBasedIndex.getInstance().processValues(LatexExternalCommandIndex.id, cmdWithSlash, null, { file, value ->
                 val dependency = LatexPackage.create(file)
Repository: hannah-sten/texify-idea
Issue: {outputDir} and {mainFileParent} are not replaced for auxiliary path, auxiliary path is not used

#### Type of JetBrains IDE (IntelliJ, PyCharm, etc.) and version
PyCharm Professional Edition 2021.3.3 

#### Operating System 
<!-- Windows, Ubuntu, Arch Linux, MacOS, etc. -->
Windows 10 / Windows 11

#### TeXiFy IDEA version

0.7.15


#### Minimal example to reproduce the problem

Paste "{mainFileParent}/out/auxil" or "{outputDir}/out/auxil" into the "Directory for auxiliary files" field of the LaTeX configuration template

Paste any other path into the auxilary path filed

#### Expected behavior

The placeholders are replaced for new Run Configuations when running any LaTeX file for the first time, just like it is done for the output path

The auxiliary files are placed into the directory specified in the field

#### Actual behavior

The placeholders are not replaced, files are placed into the output path directory.


Changed files:
src/nl/hannahsten/texifyidea/run/latex/LatexRunConfiguration.kt

diff --git a/src/nl/hannahsten/texifyidea/run/latex/LatexRunConfiguration.kt b/src/nl/hannahsten/texifyidea/run/latex/LatexRunConfiguration.kt
index a1d663489..6a25d6818 100644
--- a/src/nl/hannahsten/texifyidea/run/latex/LatexRunConfiguration.kt
+++ b/src/nl/hannahsten/texifyidea/run/latex/LatexRunConfiguration.kt
@@ -103,6 +103,8 @@ class LatexRunConfiguration constructor(
             field = value
             this.outputPath.mainFile = value
             this.outputPath.contentRoot = getMainFileContentRoot()
+            this.auxilPath.mainFile = value
+            this.auxilPath.contentRoot = getMainFileContentRoot()
         }
 
     // Save the psifile which can be used to check whether to create a bibliography based on which commands are in the psifile
Repository: hannah-sten/texify-idea
Issue: LatexLineBreakInspection triggered incorrectly 

#### Type of JetBrains IDE (IntelliJ, PyCharm, etc.) and version
IntelliJ 2020.2

#### Operating System 
macOS

#### TeXiFy IDEA version
Latest alpha

#### Description
The following bit of text incorrectly triggers the `Sentence does not start on a new line` Inspection.

#### Minimal example to reproduce the problem

```latex
This is an abbreviation (ABC). % commemt
More text here.
```



Changed files:
src/nl/hannahsten/texifyidea/inspections/latex/LatexLineBreakInspection.kt, test/nl/hannahsten/texifyidea/inspections/latex/LatexLineBreakInspectionTest.kt

diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexLineBreakInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexLineBreakInspection.kt
index 4e6d4f529..f33211117 100644
--- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexLineBreakInspection.kt
+++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexLineBreakInspection.kt
@@ -47,8 +47,9 @@ open class LatexLineBreakInspection : TexifyInspectionBase() {
                 val startOffset = matcher.start()
                 val endOffset = matcher.end() + (endLine - offset)
 
-                // Do not trigger the inspection when in a comment.
-                if (file.findElementAt(startOffset + text.startOffset)?.isComment() == true) {
+                val element = file.findElementAt(startOffset + text.startOffset)
+                // Do not trigger the inspection when in a comment or when a comment starts directly after.
+                if ((element?.isComment() == true) || (element?.nextSiblingIgnoreWhitespace()?.isComment() == true)) {
                     continue
                 }
 
diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/LatexLineBreakInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/LatexLineBreakInspectionTest.kt
index d1ab3f4b5..db6ce91bc 100644
--- a/test/nl/hannahsten/texifyidea/inspections/latex/LatexLineBreakInspectionTest.kt
+++ b/test/nl/hannahsten/texifyidea/inspections/latex/LatexLineBreakInspectionTest.kt
@@ -14,6 +14,29 @@ This e<weak_warning descr="Sentence does not start on a new line">tc. is missing
         myFixture.checkHighlighting()
     }
 
+    fun testNoWarning() {
+        myFixture.configureByText(LatexFileType, """
+            First sentence.
+            Second sentence.
+        """.trimIndent())
+        myFixture.checkHighlighting()
+    }
+
+    fun testNoWarningWithComment() {
+        myFixture.configureByText(LatexFileType, """
+            This is an abbreviation (ABC). % commemt
+            More text here.
+        """.trimIndent())
+        myFixture.checkHighlighting()
+    }
+
+    fun testNoWarningInMathMode() {
+        myFixture.configureByText(LatexFileType, """
+            \\[ Why. would. you. do. this. \\]
+        """.trimIndent())
+        myFixture.checkHighlighting()
+    }
+
     fun testQuickfix() {
         myFixture.configureByText(LatexFileType,
         """
Repository: hannah-sten/texify-idea
Issue: "Insert normal space after abbreviation" overrides first character from the next word

#### Type of JetBrains IDE (IntelliJ, PyCharm, etc.) and version
PyCharm 2019.2.3 (Professional Edition)

#### TeXiFy IDEA version
0.6.6

#### What I did (steps to reproduce)
Smallest example, typing:
`e.g me.
`
Then the plugin suggest that "Abbreviation is not followed by a normal space" and suggests to "insert normal space".
When I accept the suggestion:
#### Expected behavior
`e.g\\ me.
`
#### Actual behavior
`e.g \\ e.
`

Changed files:
src/nl/hannahsten/texifyidea/inspections/latex/LatexSpaceAfterAbbreviationInspection.kt
src/nl/hannahsten/texifyidea/util/Magic.kt

diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexSpaceAfterAbbreviationInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexSpaceAfterAbbreviationInspection.kt
index 3f708a38b..3a751099e 100644
--- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexSpaceAfterAbbreviationInspection.kt
+++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexSpaceAfterAbbreviationInspection.kt
@@ -59,8 +59,8 @@ open class LatexSpaceAfterAbbreviationInspection : TexifyInspectionBase() {
 
                 descriptors.add(manager.createProblemDescriptor(
                         text,
-                        TextRange(matchRange.last - 1, matchRange.last + 1),
-                        "Abbreviation is not followed by a normal space",
+                        TextRange(matchRange.last - 2, matchRange.last),
+                        "Abbreviation should be followed by a normal space",
                         ProblemHighlightType.WEAK_WARNING,
                         isOntheFly,
                         NormalSpaceFix(matchRange)
@@ -102,8 +102,8 @@ open class LatexSpaceAfterAbbreviationInspection : TexifyInspectionBase() {
         }
 
         private fun replaceNormalText(document: Document, normalText: LatexNormalText) {
-            val start = normalText.textOffset + whitespaceRange.last
-            val end = normalText.textOffset + whitespaceRange.last + 1
+            val start = normalText.textOffset + whitespaceRange.last - 1
+            val end = normalText.textOffset + whitespaceRange.last
             document.replaceString(start, end, "\\\\ ")
         }
     }
diff --git a/src/nl/hannahsten/texifyidea/util/Magic.kt b/src/nl/hannahsten/texifyidea/util/Magic.kt
index ba107059e..c7836e2d6 100644
--- a/src/nl/hannahsten/texifyidea/util/Magic.kt
+++ b/src/nl/hannahsten/texifyidea/util/Magic.kt
@@ -344,7 +344,7 @@ object Magic {
          * `i.e.`. Single period abbreviations are not being detected as they can easily be confused with two letter words
          * at the end of the sentence (also localisation...) For this there is a quickfix in [LatexLineBreakInspection].
          */
-        @JvmField val abbreviation = RegexPattern.compile("[0-9A-Za-z.]+\\\\.[A-Za-z](\\\\.|\\\\s)")!!
+        @JvmField val abbreviation = RegexPattern.compile("[0-9A-Za-z.]+\\\\.[A-Za-z](\\\\.\\\\s)")!!
 
         /**
          * Matches all comments, starting with % and ending with a newline.
Repository: hannah-sten/texify-idea
Issue: inverse search on evince in linux takes to the top of the latex document

<!-- **Note**: you can discard the template below if you are requesting support or proposing a new feature. -->

#### Type of JetBrains IDE (IntelliJ, PyCharm, etc.) and version
Pycharm

#### Operating System (Windows, Linux, MacOS, etc.)
Linux

#### TeXiFy IDEA version
0.6.7

#### What I did (steps to reproduce)
Compiled a latex file with Texify idea

#### Expected behavior
Inverse search from ubuntu (ctrl + click) will take me to that part of the latex file in pycharm.

#### Actual behavior
ctrl + click takes me to the top of the latex file.

#### (if applicable) The full stacktrace of the exception thrown
```

```

Changed files:
src/nl/hannahsten/texifyidea/run/linuxpdfviewer/evince/EvinceInverseSearchListener.kt

diff --git a/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/evince/EvinceInverseSearchListener.kt b/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/evince/EvinceInverseSearchListener.kt
index c12d51229..facc84409 100644
--- a/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/evince/EvinceInverseSearchListener.kt
+++ b/src/nl/hannahsten/texifyidea/run/linuxpdfviewer/evince/EvinceInverseSearchListener.kt
@@ -52,7 +52,7 @@ class EvinceInverseSearchListener {
 
                     // Get the location represented by the struct
                     val lineNumberLine = bufferedReader.readLine()
-                    val lineNumberString = lineNumberLine.substring(lineNumberLine.indexOf("int32") + 6, lineNumberLine.indexOf("int32") + 7)
+                    val lineNumberString = lineNumberLine.substring(lineNumberLine.indexOf("int32") + 6, lineNumberLine.length).trim()
                     val lineNumber = Integer.parseInt(lineNumberString)
 
                     // Sync the IDE
Repository: hannah-sten/texify-idea
Issue: "If statement is not closed" with `\\newif`

<!-- **Note**: you can discard the template below if you are proposing a new feature. -->

#### Type of JetBrains IDE (IntelliJ, PyCharm, etc.) and version

IntelliJ IDEA 2019.3.1 (Ultimate Edition)
Build #IU-193.5662.53, built on December 18, 2019

#### Operating System 
<!--(Windows, Ubuntu, Arch Linux, MacOS, etc.)-->

Arch Linux (up to date)

#### TeXiFy IDEA version

0.7-alpha.50

#### What I did (steps to reproduce)

```latex
\\newif\\ifusechaptertoc
```

#### Expected behavior

TeXiFy says nothing.

#### Actual behavior

TeXiFy's inspection "If statement is not closed" is triggered on `\\ifusechaptertoc`.

It's the `if` in the name that triggers the inspection. I believe TeXiFy does not understand that it is declared here and not used.

Changed files:
src/nl/hannahsten/texifyidea/util/Magic.kt, src/nl/hannahsten/texifyidea/inspections/latex/LatexNonMatchingIfInspection.kt

diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/LatexNonMatchingIfInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/LatexNonMatchingIfInspection.kt
index b2ca0cbe5..8eab69ea8 100644
--- a/src/nl/hannahsten/texifyidea/inspections/latex/LatexNonMatchingIfInspection.kt
+++ b/src/nl/hannahsten/texifyidea/inspections/latex/LatexNonMatchingIfInspection.kt
@@ -10,6 +10,7 @@ import nl.hannahsten.texifyidea.psi.LatexCommands
 import nl.hannahsten.texifyidea.util.Magic
 import nl.hannahsten.texifyidea.util.files.commandsInFile
 import nl.hannahsten.texifyidea.util.matches
+import nl.hannahsten.texifyidea.util.previousCommand
 import java.util.*
 
 /**
@@ -46,7 +47,7 @@ open class LatexNonMatchingIfInspection : TexifyInspectionBase() {
 
                 stack.pop()
             }
-            else if (Magic.Pattern.ifCommand.matches(name) && name !in Magic.Command.ignoredIfs) {
+            else if (Magic.Pattern.ifCommand.matches(name) && name !in Magic.Command.ignoredIfs && command.previousCommand()?.name != "\\\\newif") {
                 stack.push(command)
             }
         }
diff --git a/src/nl/hannahsten/texifyidea/util/Magic.kt b/src/nl/hannahsten/texifyidea/util/Magic.kt
index 75eee3dc4..c068a53d0 100644
--- a/src/nl/hannahsten/texifyidea/util/Magic.kt
+++ b/src/nl/hannahsten/texifyidea/util/Magic.kt
@@ -400,7 +400,7 @@ object Magic {
          * All commands that at first glance look like \\if-esque commands, but that actually aren't.
          */
         @JvmField
-        val ignoredIfs = hashSetOf("\\\\newif", "\\\\iff", "\\\\ifthenelse")
+        val ignoredIfs = hashSetOf("\\\\newif", "\\\\iff", "\\\\ifthenelse", "\\\\iftoggle")
 
         /**
          * List of all TeX style primitives.
Repository: hannah-sten/texify-idea
Issue: label prefixes predefined in a newcommand definition not working 

#### Type of JetBrains IDE (IntelliJ, PyCharm, etc.) and version
IntelliJ 2020.2.1

#### Operating System 
macOS


#### TeXiFy IDEA version
current master branch

#### Description
Even though you have a [test](https://github.com/Hannah-Sten/TeXiFy-IDEA/blob/3a59b5bdfb305798675ac714430ed1bc9cd12958/test/nl/hannahsten/texifyidea/inspections/latex/LatexFigureNotReferencedInspectionTest.kt#L35) that should cover this, in a real project this is not working for me. If I copy the example from the test into an empty project, I still get a `Unresolved reference 'fig:test.png'` warning.

There is a closed [issue](https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/1493) and corresponding [PR](https://github.com/Hannah-Sten/TeXiFy-IDEA/pull/1507), but this did apparently not fix it. Or am I doing something wrong?


Changed files:
src/nl/hannahsten/texifyidea/run/latex/logtab/LatexFileStack.kt, src/nl/hannahsten/texifyidea/util/Labels.kt

diff --git a/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexFileStack.kt b/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexFileStack.kt
index 33b7e418c..b34f4b77a 100644
--- a/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexFileStack.kt
+++ b/src/nl/hannahsten/texifyidea/run/latex/logtab/LatexFileStack.kt
@@ -95,7 +95,7 @@ class LatexFileStack(
                 if (notClosedNonFileOpenParentheses > 0) notClosedNonFileOpenParentheses--
                 else {
                     if (isEmpty()) {
-                        throw TeXception("Extra closing parenthesis: could not close a file which was not opened. Please report the log output to the issue tracker.")
+                        throw TeXception("Extra closing parenthesis: could not close a file which was not opened. Please report the log output to the issue tracker. Line content: $line")
                     }
                     pop()
                 }
diff --git a/src/nl/hannahsten/texifyidea/util/Labels.kt b/src/nl/hannahsten/texifyidea/util/Labels.kt
index 8b7e3ea08..47c609a12 100644
--- a/src/nl/hannahsten/texifyidea/util/Labels.kt
+++ b/src/nl/hannahsten/texifyidea/util/Labels.kt
@@ -164,7 +164,8 @@ fun PsiElement.extractLabelName(): String {
             val info = CommandManager.labelAliasesInfo.getOrDefault(name, null)
             val position = info?.positions?.firstOrNull() ?: 0
             val prefix = info?.prefix ?: ""
-            prefix + this.requiredParameter(position)
+            // Optional and required parameters both count as parameters
+            prefix + this.parameterList.getOrNull(position)?.text?.drop(1)?.dropLast(1)
         }
         is LatexEnvironment -> this.label ?: ""
         else -> text
Repository: hannah-sten/texify-idea
Issue: Phi and Varphi text representations are mixed up

Version: 0.7.32

Minimal code to recreate issue:

```
% Preamble
\\documentclass[12pt]{article}

% Packages
\\usepackage{amsmath}

% Document
\\begin{document}

	\\[
		\\phi(24)
	\\]

\\end{document}
```

When compiled, I see this character: ɸ
The textual preview, however, shows this character: φ

Using `varphi` reverses the characters

Changed files:
src/nl/hannahsten/texifyidea/lang/commands/LatexGreekCommand.kt

diff --git a/src/nl/hannahsten/texifyidea/lang/commands/LatexGreekCommand.kt b/src/nl/hannahsten/texifyidea/lang/commands/LatexGreekCommand.kt
index 1e8b0f0c0..7070c8d3d 100644
--- a/src/nl/hannahsten/texifyidea/lang/commands/LatexGreekCommand.kt
+++ b/src/nl/hannahsten/texifyidea/lang/commands/LatexGreekCommand.kt
@@ -55,8 +55,8 @@ enum class LatexGreekCommand(
     UPSILON("upsilon", display = "υ", collapse = true),
     CAPITAL_UPSILON("Upsilon", display = "ϒ", collapse = true),
     CAPITAL_UPSILON_VARIANT("Upsilon", dependency = AMSMATH, collapse = true),
-    PHI_STRAIGHT("phi", display = "φ", collapse = true),
-    PHI_CURLY("varphi", display = "ϕ", collapse = true),
+    PHI_STRAIGHT("phi", display = "ϕ", collapse = true),
+    PHI_CURLY("varphi", display = "φ", collapse = true),
     CAPITAL_PHI("Phi", display = "Φ", collapse = true),
     CAPITAL_PHI_VARIANT("varPhi", dependency = AMSMATH, collapse = true),
     CHI("chi", display = "χ", collapse = true),
Repository: hannah-sten/texify-idea
Issue: `Forward Search` action can be triggered from non-LaTeX files

#### Type of JetBrains IDE (IntelliJ, PyCharm, etc.) and version
IntelliJ IDEA 2023.1 (Community Edition)

#### Operating System 
Windows 10

#### TeXiFy IDEA version
0.7.29

#### What I did (steps to reproduce)
- Assign a mouse shortcut to the `Forward Search` action (`Double Click`)
- Compile LaTeX file with built-in PDF viewer enabled
- Open and focus non-LaTeX file
- Trigger aforementioned shortcut (from the non-LaTeX file)

#### Minimal example to reproduce the problem
<details><summary>Any files will do</summary>

> `test.tex`
```latex
\\documentclass{article}
\\begin{document}
    test
    \\newpage
    test
\\end{document}
```

> `test.kt`
```kotlin
val test = "test"
```
</details>

#### Expected behavior
The `Forward Search` action isn't triggered.

#### Actual behavior
The `Forward Search` action is triggered regardless.
It fails to properly determine the corresponding position in the PDF document, but it still focuses the PDF viewer and annoyingly navigates to the first page.

Changed files:
src/nl/hannahsten/texifyidea/action/ForwardSearchAction.kt

diff --git a/src/nl/hannahsten/texifyidea/action/ForwardSearchAction.kt b/src/nl/hannahsten/texifyidea/action/ForwardSearchAction.kt
index f33b2b7ce..fe11d7e92 100644
--- a/src/nl/hannahsten/texifyidea/action/ForwardSearchAction.kt
+++ b/src/nl/hannahsten/texifyidea/action/ForwardSearchAction.kt
@@ -2,10 +2,12 @@ package nl.hannahsten.texifyidea.action
 
 import com.intellij.openapi.actionSystem.ActionUpdateThread
 import com.intellij.openapi.actionSystem.AnActionEvent
+import com.intellij.openapi.actionSystem.CommonDataKeys
 import com.intellij.openapi.fileEditor.TextEditor
 import com.intellij.openapi.project.Project
 import com.intellij.openapi.vfs.VirtualFile
 import nl.hannahsten.texifyidea.TexifyIcons
+import nl.hannahsten.texifyidea.file.LatexFileType
 import nl.hannahsten.texifyidea.run.linuxpdfviewer.InternalPdfViewer
 import nl.hannahsten.texifyidea.run.pdfviewer.ExternalPdfViewer
 import nl.hannahsten.texifyidea.run.pdfviewer.PdfViewer
@@ -17,11 +19,7 @@ open class ForwardSearchAction(var viewer: PdfViewer? = null) : EditorAction(
 ) {
 
     override fun actionPerformed(file: VirtualFile, project: Project, textEditor: TextEditor) {
-        if (viewer == null) return
-
-        if (!viewer!!.isAvailable()) {
-            return
-        }
+        if (viewer?.isAvailable() != true || file.fileType !is LatexFileType) return
 
         val document = textEditor.editor.document
         val line = document.getLineNumber(textEditor.editor.caretModel.offset) + 1
@@ -35,6 +33,7 @@ open class ForwardSearchAction(var viewer: PdfViewer? = null) : EditorAction(
 
     override fun update(e: AnActionEvent) {
         e.presentation.isEnabledAndVisible = e.project?.selectedRunConfig()?.pdfViewer == viewer
+            && e.getData(CommonDataKeys.VIRTUAL_FILE)?.fileType is LatexFileType
     }
 
     override fun getActionUpdateThread() = ActionUpdateThread.BGT
Repository: kordlib/kord
Issue: Trying to mention the everyone role results in a malformed @@everyone mention in the client

```kotlin
channel.createMessage(guild.everyoneRole.mention)
```

results in:
`@@everyone`

This behaviour on is correct according the official docs, but it seems like the client stumbles over the special everyone type. Using the literal `@everyone` works fine though.

Proposed solution:
Introduce a check on `RoleBehavior#mention` that checks for `guildId.value == id.value` and returns the literal `@everyone` on true instead.

Changed files:
core/src/main/kotlin/com/gitlab/kordlib/core/behavior/RoleBehavior.kt

diff --git a/core/src/main/kotlin/com/gitlab/kordlib/core/behavior/RoleBehavior.kt b/core/src/main/kotlin/com/gitlab/kordlib/core/behavior/RoleBehavior.kt
index 01a18c70de..ea9d068296 100644
--- a/core/src/main/kotlin/com/gitlab/kordlib/core/behavior/RoleBehavior.kt
+++ b/core/src/main/kotlin/com/gitlab/kordlib/core/behavior/RoleBehavior.kt
@@ -37,7 +37,11 @@ interface RoleBehavior : Entity, Strategizable {
     /**
      * The raw mention of this entity.
      */
-    val mention: String get() = "<@&${id.value}>"
+    val mention: String
+        get() {
+            return if (guildId.value == id.value) "@everyone"
+            else "<@&${id.value}>"
+        }
 
     /**
      * Requests to change the [position] of this role.
Repository: horizontalsystems/unstoppable-wallet-android
Issue: Import Wallet: After successful import back button takes user back to import screen after 

After user has successfully imported the wallet the back button shouldn't take user beyond the Balance tab. 

In its current state it's possible to return back to New/Import wallet screens even after a successful import. This is somewhat confusing and leaves user on a screen that's impossible to leave without reimporting a wallet again or setting up a new one. (Killing the app takes user back to the restored wallet) 

Changed files:
app/src/main/java/io/horizontalsystems/bankwallet/modules/pin/PinActivity.kt

diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/pin/PinActivity.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/pin/PinActivity.kt
index b65230acc..8e9cc30d1 100644
--- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/pin/PinActivity.kt
+++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/pin/PinActivity.kt
@@ -134,7 +134,7 @@ class PinActivity : BaseActivity(), NumPadItemsAdapter.Listener, FingerprintAuth
         viewModel.navigateToMainLiveEvent.observe(this, Observer {
             Handler().postDelayed({
                 HudHelper.showSuccessMessage(activity = this)
-                MainModule.start(this)
+                MainModule.startAsNewTask(this)
                 finish()
             }, 300)
         })
Repository: horizontalsystems/unstoppable-wallet-android
Issue: Transaction displaying wrong value

Transaction amount 0.0022625 displayed as 0.00226251

Changed files:
app/src/main/java/io/horizontalsystems/bankwallet/viewHelpers/ValueFormatter.kt

diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/viewHelpers/ValueFormatter.kt b/app/src/main/java/io/horizontalsystems/bankwallet/viewHelpers/ValueFormatter.kt
index 163737f75..b392a1399 100644
--- a/app/src/main/java/io/horizontalsystems/bankwallet/viewHelpers/ValueFormatter.kt
+++ b/app/src/main/java/io/horizontalsystems/bankwallet/viewHelpers/ValueFormatter.kt
@@ -13,7 +13,6 @@ object ValueFormatter {
             val format: NumberFormat = NumberFormat.getInstance()
             format.minimumFractionDigits = 2
             format.maximumFractionDigits = 8
-            format.roundingMode = RoundingMode.CEILING
             return format
         }
Repository: horizontalsystems/unstoppable-wallet-android
Issue: Wrong rounding numbers

3734.1 becomes 3735 whereas it should be 3734



Changed files:
app/src/main/java/io/horizontalsystems/bankwallet/viewHelpers/ValueFormatter.kt

diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/viewHelpers/ValueFormatter.kt b/app/src/main/java/io/horizontalsystems/bankwallet/viewHelpers/ValueFormatter.kt
index 60364583b..36ffad5db 100644
--- a/app/src/main/java/io/horizontalsystems/bankwallet/viewHelpers/ValueFormatter.kt
+++ b/app/src/main/java/io/horizontalsystems/bankwallet/viewHelpers/ValueFormatter.kt
@@ -21,7 +21,7 @@ object ValueFormatter {
             val format: NumberFormat = NumberFormat.getInstance()
             format.minimumFractionDigits = 2
             format.maximumFractionDigits = 2
-            format.roundingMode = RoundingMode.CEILING
+            format.roundingMode = RoundingMode.HALF_EVEN
             return format
         }
Repository: horizontalsystems/unstoppable-wallet-android
Issue: TX fee: in send controller and send confirmation controller doesn't match.

tried sending 0.1 ETH in dev build no.467. The send controller showed fee as $0.01 ut the send confirmation controller showed it as 0$.

I suspect it might be due to rounding. Note that we shouldn't be rounding the values in send AND send confirmation controllers


Changed files:
app/src/main/java/io/horizontalsystems/bankwallet/modules/send/SendModule.kt, app/src/main/java/io/horizontalsystems/bankwallet/viewHelpers/ValueFormatter.kt

diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/SendModule.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/SendModule.kt
index 054277d80..a7badc872 100644
--- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/SendModule.kt
+++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/SendModule.kt
@@ -114,7 +114,7 @@ object SendModule {
                 ValueFormatter.format(this.coinValue)
             }
             is SendModule.AmountInfo.CurrencyValueInfo -> {
-                ValueFormatter.formatSimple(this.currencyValue)
+                ValueFormatter.format(this.currencyValue)
             }
         }
     }
diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/viewHelpers/ValueFormatter.kt b/app/src/main/java/io/horizontalsystems/bankwallet/viewHelpers/ValueFormatter.kt
index 3e3d4af4c..e4bd7b535 100644
--- a/app/src/main/java/io/horizontalsystems/bankwallet/viewHelpers/ValueFormatter.kt
+++ b/app/src/main/java/io/horizontalsystems/bankwallet/viewHelpers/ValueFormatter.kt
@@ -105,9 +105,4 @@ object ValueFormatter {
         return spannable
     }
 
-    fun formatSimple(currencyValue: CurrencyValue): String? {
-        val result = currencyValue.value.setScale(2, RoundingMode.HALF_EVEN)
-        val formatted = currencyFormatter.format(result)
-        return "${currencyValue.currency.symbol}$formatted"
-    }
 }
Repository: horizontalsystems/unstoppable-wallet-android
Issue: Transactions Tab: displays transactions from previously restored accounts

That bug was spotted on IOS first. I heaven't tested it on Android as such but it should be an issue on Android as well. https://github.com/horizontalsystems/unstoppable-wallet-ios/issues/809



Been testing EOS restore feature and have repeatedly noticed the case when the transactions list for EOS displayed transactions from both account but should have been one.

Upon further testing it seems to be a bug with GUI cache. The GUI controller cache is not being cleared upon unlinking. If the users adds a new account before the GUI is cleared then a transactions list for the coin will be displaying transactions from the newly linked as well as the unlinked accounts.

Killing the app displays the GUI properly

Changed files:
app/src/main/java/io/horizontalsystems/bankwallet/modules/transactions/PoolRepo.kt

diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/transactions/PoolRepo.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/transactions/PoolRepo.kt
index 76d67198c..abd11ae64 100644
--- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/transactions/PoolRepo.kt
+++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/transactions/PoolRepo.kt
@@ -14,6 +14,14 @@ class PoolRepo {
     private var activePoolCoinCodes = listOf<Coin>()
 
     fun activatePools(coinCodes: List<Coin>) {
+
+        // remove pools for unused coins
+        pools.map { it.key }.forEach { poolCoin ->
+            if (!coinCodes.contains(poolCoin)) {
+                pools.remove(poolCoin)
+            }
+        }
+
         coinCodes.forEach { coinCode ->
             if (!pools.containsKey(coinCode)) {
                 pools[coinCode] = Pool(Pool.State(coinCode))
Repository: horizontalsystems/unstoppable-wallet-android
Issue:  EOS based Tokens: After the user adds a coin there seem to be coin balance not syncing

*when app killed and restarted, all EOS-based tokens are sync

Changed files:
app/src/main/java/io/horizontalsystems/bankwallet/core/adapters/EosAdapter.kt
app/src/main/java/io/horizontalsystems/bankwallet/core/adapters/BinanceAdapter.kt

diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/core/adapters/BinanceAdapter.kt b/app/src/main/java/io/horizontalsystems/bankwallet/core/adapters/BinanceAdapter.kt
index c0a591a19..057c4d92a 100644
--- a/app/src/main/java/io/horizontalsystems/bankwallet/core/adapters/BinanceAdapter.kt
+++ b/app/src/main/java/io/horizontalsystems/bankwallet/core/adapters/BinanceAdapter.kt
@@ -30,7 +30,7 @@ class BinanceAdapter(
     }
 
     override fun stop() {
-        // handled by BinanceKitManager
+        binanceKit.unregister(asset)
     }
 
     override fun refresh() {
diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/core/adapters/EosAdapter.kt b/app/src/main/java/io/horizontalsystems/bankwallet/core/adapters/EosAdapter.kt
index faca8e52a..c1827dc88 100644
--- a/app/src/main/java/io/horizontalsystems/bankwallet/core/adapters/EosAdapter.kt
+++ b/app/src/main/java/io/horizontalsystems/bankwallet/core/adapters/EosAdapter.kt
@@ -10,8 +10,6 @@ import io.reactivex.Flowable
 import io.reactivex.Single
 import java.math.BigDecimal
 import java.math.RoundingMode
-import java.text.SimpleDateFormat
-import java.util.*
 
 class EosAdapter(override val wallet: Wallet, eos: CoinType.Eos, private val eosKit: EosKit) : IAdapter {
 
@@ -29,7 +27,7 @@ class EosAdapter(override val wallet: Wallet, eos: CoinType.Eos, private val eos
     }
 
     override fun stop() {
-        // stopped via EosKitManager
+        eosKit.unregister(token)
     }
 
     override fun refresh() {