Skip to content

Commit

Permalink
add opportunity to call 'cd ..' -- change working directory to a pare…
Browse files Browse the repository at this point in the history
…nt directory
  • Loading branch information
diffitask committed Jan 16, 2024
1 parent f2c481b commit 459b234
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ class ChangeDirectory(
val currentProjectDirectory = ideStateKeeper.currentProjectDirectory
currentProjectDirectory.refresh()

val targetDir = currentProjectDirectory.findSubdirectoryRecursively(targetDirectoryName)
val targetDir = when(targetDirectoryName) {
PARENT_DIRECTORY_NAME -> currentProjectDirectory.parentDirectory ?: error("No parent directory")
else -> currentProjectDirectory.findSubdirectoryRecursively(targetDirectoryName)
}

previousDirectory = currentProjectDirectory
ideStateKeeper.currentProjectDirectory = targetDir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.jetbrains.research.ideFormerPlugin.api.models.fileRelated.fileClasses
import org.jetbrains.research.ideFormerPlugin.api.models.fileRelated.fileFunctions.*

const val DEFAULT_DIRECTORY_NAME = "."
const val PARENT_DIRECTORY_NAME = ".."

const val UNCALLED_EXECUTE_BEFORE_RESULT_GETTING =
"Execute() must be called before getting the result. The property storing the result has not been initialized yet"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fun Routing.getChangeDirectory(logger: Logger, ideStateKeeper: IdeStateKeeper) {
logger.info("Change directory api method was saved on the api methods stack")

val response = targetDirName?.let {
"$PROJECT_DIR_WAS_CHANGED_TO $targetDirName."
"$PROJECT_DIR_WAS_CHANGED_TO '$targetDirName'."
} ?: PROJECT_DIR_REMAINS_THE_SAME

call.respondJson(response)
Expand Down

0 comments on commit 459b234

Please sign in to comment.