Skip to content

Commit 8283146

Browse files
committed
(#229) Run configuration: save all documents before executing
1 parent 2766f64 commit 8283146

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
66

7+
## [Unreleased] (2.6.0)
8+
### Changed
9+
- [#229](https://github.com/ant-druha/intellij-powershell/issues/229): the **PowerShell** run configuration will now save all the files before executing
10+
11+
This fixes the cases when the started configuration wasn't using the latest version of an edited script file.
12+
713
## [2.5.0] - 2024-03-12
814
### Fixed
915
- [#67](https://github.com/ant-druha/intellij-powershell/issues/67): An attribute block before function's `param` could lead to incorrect indentation

src/main/kotlin/com/intellij/plugin/powershell/ide/run/PowerShellProgramRunner.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import com.intellij.execution.runners.AsyncProgramRunner
88
import com.intellij.execution.runners.ExecutionEnvironment
99
import com.intellij.execution.runners.showRunContent
1010
import com.intellij.execution.ui.RunContentDescriptor
11+
import com.intellij.openapi.fileEditor.FileDocumentManager
1112
import com.intellij.openapi.rd.util.toPromise
1213
import com.intellij.openapi.rd.util.withUiContext
1314
import com.intellij.plugin.powershell.ide.PluginProjectRoot
@@ -17,7 +18,7 @@ import kotlinx.coroutines.async
1718
import org.jetbrains.concurrency.Promise
1819

1920
/**
20-
* The only purpose of this runner is to call [RunProfileState.execute] or a background thread instead of a foreground
21+
* The main purpose of this runner is to call [RunProfileState.execute] or a background thread instead of a foreground
2122
* one, as our [RunProfileState] implementation requires FS access that's only possible from the background.
2223
*/
2324
class PowerShellProgramRunner : AsyncProgramRunner<RunnerSettings>() {
@@ -31,6 +32,9 @@ class PowerShellProgramRunner : AsyncProgramRunner<RunnerSettings>() {
3132
override fun execute(environment: ExecutionEnvironment, state: RunProfileState): Promise<RunContentDescriptor?> =
3233
PluginProjectRoot.getInstance(environment.project).coroutineScope.async(Dispatchers.Default) {
3334
state as PowerShellScriptCommandLineState
35+
withUiContext {
36+
FileDocumentManager.getInstance().saveAllDocuments()
37+
}
3438
state.prepareExecution()
3539
val executionResult = state.execute(environment.executor, this@PowerShellProgramRunner)
3640
val descriptor = withUiContext { showRunContent(executionResult, environment) }

0 commit comments

Comments
 (0)