Skip to content

Commit 01f9a0c

Browse files
committed
fix FileWatch error on dir outside the project
1 parent 0f9de58 commit 01f9a0c

File tree

1 file changed

+8
-3
lines changed
  • src/main/kotlin/com/github/oldmegit/goframehelper/gf

1 file changed

+8
-3
lines changed

src/main/kotlin/com/github/oldmegit/goframehelper/gf/Gf.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,14 @@ object Gf {
3636
private fun getRelativePath(project: Project, virtualFile: VirtualFile): String {
3737
val basePathCls = Paths.get(project.basePath.toString())
3838
val filePathCls = Paths.get(virtualFile.path)
39-
var absolute = basePathCls.relativize(filePathCls).toString()
40-
if (File.separator == "\\") {
41-
absolute = absolute.replace("\\", "/")
39+
var absolute: String
40+
try {
41+
absolute = basePathCls.relativize(filePathCls).toString()
42+
if (File.separator == "\\") {
43+
absolute = absolute.replace("\\", "/")
44+
}
45+
} catch (_: Exception) {
46+
absolute = ""
4247
}
4348
return absolute
4449
}

0 commit comments

Comments
 (0)