Skip to content

Commit

Permalink
Failsafes empty lists
Browse files Browse the repository at this point in the history
Resolves #75
  • Loading branch information
Roboroads committed Jun 16, 2021
1 parent c4c5572 commit 56d22d7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- [[#34]](https://github.com/Roboroads/laravel-tinker/issues/34) Setting to change tinker execution root
### Fixed
- [[#75]](https://github.com/Roboroads/laravel-tinker/issues/75) Empty directory list of tinker consoles resulting in fatal error.
## [2.1.0]
### Added
- Dependabot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import nl.deschepers.laraveltinker.Strings

class TinkerConsoleUtil(val project: Project) {
fun getLastOpenTinkerConsole(): VirtualFile? {
return getTinkerConsoleFiles()?.last()
return getTinkerConsoleFiles()?.lastOrNull()
}

fun getLastOpenOrCreateTinkerConsole(): VirtualFile {
val lastOpen = getTinkerConsoleFiles()?.last()
val lastOpen = getTinkerConsoleFiles()?.lastOrNull()
return lastOpen ?: getTinkerConsole(ScratchFileService.Option.create_if_missing)!!
}

Expand Down

0 comments on commit 56d22d7

Please sign in to comment.