Skip to content

ability to rename tinker console files #375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ class LaravelTinkerConsolesRootType :
}
}

override fun substituteName(project: Project, file: VirtualFile): String {
val matches = Regex("_([0-9]+)$").find(file.nameWithoutExtension)
val consoleNum = if (matches != null) " (${matches.groupValues[1]})" else ""
return Strings.get("lt.console.name") + consoleNum
}

override fun substituteLanguage(project: Project, file: VirtualFile): Language? {
return ScratchFileService.getInstance().scratchesMapping.getMapping(file)
}
Expand All @@ -47,10 +41,10 @@ class LaravelTinkerConsolesRootType :
@Suppress("SwallowedException")
fun createScratchFile(
project: Project?,
fileName:String,
text: String?,
option: ScratchFileService.Option
): VirtualFile? {
val fileName = Strings.get("lt.console.filename")
return try {
WriteCommandAction.writeCommandAction(project)
.withName(Strings.get("lt.menu.action.open_new_console"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ class TinkerConsoleUtil(val project: Project) {
option: ScratchFileService.Option,
startingText: String = ""
): VirtualFile? {
getTinkerConsoleFiles()

val fileName = Strings.get("lt.console.filename")
return LaravelTinkerConsolesRootType.getInstance()
.createScratchFile(
project,
fileName,
Strings.get("lt.console.default_content") + startingText,
option
)
Expand Down