augustocdias / vscode-shell-command

A task helper to use system commands as input
MIT License
51 stars 19 forks source link

Share remembered value between tasks #71

Closed ahfakt closed 2 weeks ago

ahfakt commented 9 months ago

Different tasks can share same memory to remember by using until last '.' of the inputId parameter.

augustocdias commented 9 months ago

Hey... Things have been hectic at home and it can take a while until I can take a look on this... Please be patient and thanks for understanding

ahfakt commented 9 months ago

Main goal is remembering across launch inputs and other task inputs(build and then debug some module). 'useRememberedValue' option would be a good feature on top of this. Can be discussed about different delimiter, prefix/suffix. It was a quick suggestion.

MarcelRobitaille commented 4 weeks ago

Is this necessary? Can't you just give multiple tasks the same taskId? This example uses the same remembered value for both inputs for me:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Task 1",
            "type": "shell",
            "command": "echo ${input:input1}",
            "problemMatcher": []
        },
        {
            "label": "Task 2",
            "type": "shell",
            "command": "echo ${input:input2}",
            "problemMatcher": []
        },
    ],
    "inputs": [
        {
            "id": "input1",
            "type": "command",
            "command": "shellCommand.execute",
            "args": {
                "taskId": "thesame",
                "command": "cat ${file}",
                "cwd": "${workspaceFolder}",
                                "rememberPrevious": true
            }
        },
        {
            "id": "input2",
            "type": "command",
            "command": "shellCommand.execute",
            "args": {
                "taskId": "thesame",
                "command": "cat ${file}",
                "cwd": "${workspaceFolder}",
                                "rememberPrevious": true
            }
        }
    ]
}
ahfakt commented 4 weeks ago

The problem occurs when the same taskId is used in different groups of inputs. Launch inputs, workspace task inputs, user task inputs. That was the problem, I don't know if it still exists.

MarcelRobitaille commented 3 weeks ago

For me it's working across launch and tasks.

tasks.json:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Echo Project File",
      "type": "shell",
      "command": "echo ${input:taskInput}",
      "problemMatcher": []
    }
  ],
  "inputs": [
    {
      "id": "taskInput",
      "type": "command",
      "command": "shellCommand.execute",
      "args": {
        "command": "cat ${file}",
        "taskId": "thesame",
        "rememberPrevious": true,
      }
    }
  ]
}

launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch configuration",
            "request": "launch",
            "program": "echo ${input:launchInput}",
            "args": [],
        }
    ],
    "inputs": [
        {
            "id": "launchInput",
            "type": "command",
            "command": "shellCommand.execute",
            "args": {
                "command": "cat ${file}",
                "taskId": "thesame",
                "rememberPrevious": true,
            }
        }
    ]
}
MarcelRobitaille commented 2 weeks ago

If you still experience this in 1.11.0 or later, then please open an issue. This is a bug.

MarcelRobitaille commented 2 weeks ago

Please try 1.12.0