Skip to content

Commit

Permalink
viartemev#201 ignore whitespaces
Browse files Browse the repository at this point in the history
impl
  • Loading branch information
ikopysov committed Sep 28, 2019
1 parent 4eb2be3 commit 1aee2e5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ class RequestMappingContributor(private val annotationSearcher: (string: String,
}

override fun getItemsByName(name: String, pattern: String, project: Project, includeNonProjectItems: Boolean): Array<NavigationItem> {
val normalizedName = name.replace("\\s+".toRegex(), " ").trim()
return navigationItems
.filter { it.name == name }
.filter { it.name == normalizedName }
.toTypedArray()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@ class RequestMappingModel(project: Project) : FilteringGotoByModel<FileType>(pro
override fun willOpenEditor(): Boolean = false

override fun matches(popupItem: String, userPattern: String): Boolean {
return if (userPattern == "/") {
val normalizedUserPattern = userPattern.replace("\\s+".toRegex(), " ").trim()
return if (normalizedUserPattern == "/") {
true
} else if (!userPattern.contains('/')) {
} else if (!normalizedUserPattern.contains('/')) {
val (method, path) = popupItem.split(" ", limit = 2)
path.contains(userPattern) || method.contains(userPattern, ignoreCase = true)
path.contains(normalizedUserPattern) || method.contains(normalizedUserPattern, ignoreCase = true)
} else {
Path.isSubpathOf(
PopupPath(popupItem).toPath(),
RequestedUserPath(userPattern).toPath()
RequestedUserPath(normalizedUserPattern).toPath()
)
}
}
Expand Down

0 comments on commit 1aee2e5

Please sign in to comment.