geddski / macros

macros support for VS Code
MIT License
165 stars 36 forks source link

After last VS Code update, something doesn't works fine #53

Open ottopic opened 5 years ago

ottopic commented 5 years ago

I'm using this extension from 8 months, but I think from last VS code version 1.37.1 my macro doesn't work anymore. ${CLIPBOARD} is not replaced anymore from selected text. In some case all snippet is pasted replacing all document text instead insert it after the newline.

Anyone can help me?

settings.json

`

"macros": { 
    "printr": [
        "editor.action.smartSelect.grow",
        "editor.action.clipboardCopyAction",
        "editor.action.insertLineAfter",
        {
         "command": "editor.action.insertSnippet",
            "args": {
                "name": "customprintr",
                "langId": "php",
            }
       },
       "editor.action.insertLineAfter",
       "editor.action.clipboardCopyAction",
    ]
}, 

`

snippets/php.json

`

 "customprintr": { 
    "prefix": "customprintr",
    "body": [
        "\t",
        "\t    echo '<pre style=\"text-align:left\">';",
        "\t    \\$printMe = ${CLIPBOARD}; print_r(\\$printMe);",
        "\t    echo '</pre>';",
        "\t    die;",
        "\t",
        "\t"
    ],
    "description": "Insert custom print_r"
},
"br": {
    "prefix": "br",
    "body": ["<br />"]
}

`

ottopic commented 5 years ago

@geddski are you supporting this extension? According with vs code team the problem is that now clipboard is async.

vscode.commands.executeCommand which returns a promise but that extension isn't awaiting those promises, see https://github.com/geddski/macros/blob/master/extension.js#L34. Reading from the clipboard is now async and mostly like a command is started before the previous command is done.

Probably it can be fixed add 'await' param before vscode.commands.executeCommand. https://code.visualstudio.com/api/references/commands

oloryn commented 4 years ago

@jeff-hykin has made a fork of this extension: macro-commander, and it's available in the marketplace. It appears to handle this problem and has been working for me in the current version of VSCode.

jeff-hykin commented 4 years ago

Yeah I had issues with async commands so I added an await to all of them. Although I don't have time at the moment to add more features, I do plan on actively maintaining the extension in terms of bugs and merging pull requests.