Skip to content

Commit

Permalink
fix: allow spaces in folder and files names [IDE-684] (#624)
Browse files Browse the repository at this point in the history
* fix: allow spaces in folder and files names

* docs: update CHANGELOG.md
  • Loading branch information
bastiandoetsch authored Oct 13, 2024
1 parent f09ce0a commit 4222c0d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
- limit warn / error messages to 500 characters
- use dumb aware to limit scans during startup
- add no_proxy environment variable, if proxy exceptions are defined
- be able to process findings in folder and file names that contain URL encoding

## [2.9.1]
### Fixed
Expand Down
9 changes: 8 additions & 1 deletion src/main/kotlin/io/snyk/plugin/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import java.io.File
import java.io.FileNotFoundException
import java.net.URI
import java.nio.file.Path
import java.nio.file.Paths
import java.util.Objects.nonNull
import java.util.SortedSet
import java.util.concurrent.TimeUnit
Expand Down Expand Up @@ -390,7 +391,7 @@ fun String.toVirtualFile(): VirtualFile {
return if (!this.startsWith("file://")) {
StandardFileSystems.local().refreshAndFindFileByPath(this) ?: throw FileNotFoundException(this)
} else {
VirtualFileManager.getInstance().refreshAndFindFileByUrl(this.toVirtualFileURL())
VirtualFileManager.getInstance().refreshAndFindFileByNioPath(convertUriToPath(this.toVirtualFileURL()))
?: throw FileNotFoundException(this)
}
}
Expand All @@ -411,6 +412,12 @@ fun String.toVirtualFileURL(): String {
return this
}

fun convertUriToPath(encodedUri: String): Path {
val uri = URI(encodedUri)
val path = Paths.get(uri)
return path
}

fun String.isWindowsURI() = SystemUtils.IS_OS_WINDOWS && this.startsWith("file://")

fun VirtualFile.urlContainsDriveLetter() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class LanguageServerBulkFileListener : SnykBulkFileListener() {

VirtualFileManager.getInstance().asyncRefresh()
invokeLater {
if (SnykPluginDisposable.getInstance(project).isDisposed() || project.isDisposed) return@invokeLater
if (project.isDisposed || SnykPluginDisposable.getInstance(project).isDisposed()) return@invokeLater
DaemonCodeAnalyzer.getInstance(project).restart()
}
}
Expand Down

0 comments on commit 4222c0d

Please sign in to comment.