Skip to content

Commit

Permalink
Add the correct ERL and elixir arguments for starting IEx depending o…
Browse files Browse the repository at this point in the history
…n the version of elixir sdk
  • Loading branch information
ashleysommer authored and KronicDeth committed May 8, 2024
1 parent 2818584 commit c76ecda
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
## v17.0.1

### Bug Fixes
* [#3491](https://github.com/KronicDeth/intellij-elixir/pull/3491) - [neominik](https://github.com/neominik)
* [#3491](https://github.com/KronicDeth/intellij-elixir/pull/3491) - [@neominik](https://github.com/neominik)
* Render code snippets that are not links.
* [#3562](https://github.com/KronicDeth/intellij-elixir/pull/3562) - [@ashleysommer](https://github.com/ashleysommer)
* Add the correct ERL and elixir arguments for starting IEx depending on the version of Elixir SDK.

## v17.0.0

Expand Down
1 change: 1 addition & 0 deletions resources/META-INF/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ <h1>v17.0.1</h1>
<p>Bug Fixes</p>
<ul>
<li>Render code snippets that are not links.</li>
<li>Add the correct ERL and elixir arguments for starting IEx depending on the version of Elixir SDK.</li>
</ul>
</li>
</ul>
Expand Down
28 changes: 24 additions & 4 deletions src/org/elixir_lang/IEx.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.elixir_lang

import com.intellij.execution.configurations.GeneralCommandLine
import com.intellij.openapi.projectRoots.Sdk
import com.intellij.openapi.util.Version
import org.elixir_lang.Elixir.elixirSdkToEnsuredErlangSdk
import org.elixir_lang.Elixir.prependNewCodePaths

Expand All @@ -19,15 +20,34 @@ object IEx {
prependNewCodePaths(commandLine, elixirSdk, erlangSdk)
commandLine.addParameters("-elixir", "ansi_enabled", "true")
commandLine.addParameters(erlArgumentList)
addIEx(commandLine)
addIEx(commandLine, elixirSdk)
commandLine.addParameter("--no-halt")

return commandLine
}

private fun addIEx(commandLine: GeneralCommandLine) {
private fun addIEx(commandLine: GeneralCommandLine, elixirSdk: Sdk) {
commandLine.addParameter("-noshell")
commandLine.addParameters("-user", "Elixir.IEx.CLI")
commandLine.addParameter("-extra")

val elixirVersion = elixirSdk.versionString?.let { Version.parseVersion(it) }
if (elixirVersion?.lessThan(1, 15, 0) == true) {
/* Pre Elixir 1.15.0, IEx entrypoint was as Elixir.IEx.CLI start() */
commandLine.addParameters("-user", "Elixir.IEx.CLI")
commandLine.addParameter("-extra")
} else if (elixirVersion?.`is`(1, 15, 0) == true) {
/* Weird case for 1.15.0-rc1 to 1.15.0
* It had a bugged start_iex that needs to be specified differently. */
commandLine.addParameters("-s", "elixir", "start_cli")
commandLine.addParameters("-user", "elixir")
commandLine.addParameter("-extra")
commandLine.addParameters("-e", ":elixir.start_iex()")
} else {
/* Case for elixir 1.16.0+ (and 1.15.1+ from the 1.15 branch).
* We can call start_iex directly from elixir entrypoint. */
commandLine.addParameters("-s", "elixir", "start_iex")
commandLine.addParameters("-user", "elixir")
commandLine.addParameter("-extra")
}
commandLine.addParameter("+iex")
}
}

0 comments on commit c76ecda

Please sign in to comment.