@@ -12,13 +12,14 @@ import com.intellij.execution.configurations.*
12
12
import com.intellij.execution.runners.ExecutionEnvironment
13
13
import com.intellij.execution.testframework.actions.ConsolePropertiesProvider
14
14
import com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties
15
+ import com.intellij.execution.util.ProgramParametersUtil
15
16
import com.intellij.openapi.options.SettingsEditor
16
17
import com.intellij.openapi.project.Project
17
18
import com.intellij.openapi.util.NlsContexts.DialogMessage
18
19
import com.intellij.openapi.util.SystemInfo
20
+ import com.intellij.openapi.util.io.FileUtil
19
21
import com.intellij.openapi.vfs.LocalFileSystem
20
22
import com.intellij.util.execution.ParametersListUtil
21
- import com.intellij.util.io.exists
22
23
import org.jdom.Element
23
24
import org.rust.RsBundle
24
25
import org.rust.cargo.project.model.CargoProject
@@ -37,7 +38,6 @@ import org.rust.cargo.toolchain.tools.Cargo
37
38
import org.rust.cargo.toolchain.tools.isRustupAvailable
38
39
import org.rust.ide.experiments.RsExperiments
39
40
import org.rust.openapiext.isFeatureEnabled
40
- import org.rust.stdext.toPathOrNull
41
41
import java.io.File
42
42
import java.nio.file.Path
43
43
import java.nio.file.Paths
@@ -64,6 +64,17 @@ open class CargoCommandConfiguration(
64
64
65
65
private var isRedirectInput: Boolean = false
66
66
private var redirectInputPath: String? = null
67
+ private val redirectInputFile: File ?
68
+ get() {
69
+ if (! isRedirectInput) return null
70
+ if (redirectInputPath?.isNotEmpty() != true ) return null
71
+ val redirectInputPath = FileUtil .toSystemDependentName(ProgramParametersUtil .expandPathAndMacros(redirectInputPath, null , project))
72
+ var file = File (redirectInputPath)
73
+ if (! file.isAbsolute && workingDirectory != null ) {
74
+ file = File (File (workingDirectory.toString()), redirectInputPath)
75
+ }
76
+ return file
77
+ }
67
78
68
79
override fun isRedirectInput (): Boolean = isRedirectInput
69
80
@@ -127,10 +138,10 @@ open class CargoCommandConfiguration(
127
138
@Throws(RuntimeConfigurationException ::class )
128
139
override fun checkConfiguration () {
129
140
if (isRedirectInput) {
130
- val path = redirectInputPath?.toPathOrNull()
141
+ val file = redirectInputFile
131
142
when {
132
- path ?.exists() != true -> throw RuntimeConfigurationWarning (" Input file doesn't exist" )
133
- ! path.toFile() .isFile -> throw RuntimeConfigurationWarning (" Input file is not valid" )
143
+ file ?.exists() != true -> throw RuntimeConfigurationWarning (" Input file doesn't exist" )
144
+ ! file .isFile -> throw RuntimeConfigurationWarning (" Input file is not valid" )
134
145
}
135
146
}
136
147
// TODO: remove when `com.intellij.execution.process.ElevationService` supports error stream redirection
@@ -188,9 +199,7 @@ open class CargoCommandConfiguration(
188
199
fun clean (): CleanConfiguration {
189
200
val workingDirectory = workingDirectory
190
201
? : return CleanConfiguration .error(" No working directory specified" )
191
- val redirectInputFrom = redirectInputPath
192
- ?.takeIf { isRedirectInput && it.isNotBlank() }
193
- ?.let { File (it) }
202
+
194
203
val cmd = run {
195
204
val args = ParametersListUtil .parse(command)
196
205
if (args.isEmpty()) {
@@ -200,7 +209,7 @@ open class CargoCommandConfiguration(
200
209
args.first(),
201
210
workingDirectory,
202
211
args.drop(1 ),
203
- redirectInputFrom ,
212
+ redirectInputFile ,
204
213
backtrace,
205
214
channel,
206
215
env,
0 commit comments