Create new untitled file and set language mode

寵の児 提交于 2021-01-29 10:51:51

问题


I have this macro

"macros": {
    "newScratchFile": [
        "workbench.action.files.newUntitledFile",
        "workbench.action.editor.changeLanguageMode"
    ]
},

Which used to work great with this extension but it appears Microsoft broke it as some point in time.

Now when I activate it, I do get a new untitled file, and the language mode popup opens for a split second but then disappears before I get a chance to type anything.

Is there a way to fix my macro so the language picker remains open?


回答1:


I'm sorry to say it is probably the macro extension. That extension has been "quiet" for awhile and the two PR's are pretty important (see the issues) and haven't been incorporated. So the extension has been forked. I was a big fan of the original macros extension but now I use multi-command which works better.

I tried your commands in multi-command and it works flawlessly.

{
    "command": "multiCommand.newFileAndMode",
    // "interval": 250,
    "sequence": [

      "workbench.action.files.newUntitledFile",
      "workbench.action.editor.changeLanguageMode"
    ]
}

It also has support for an interval time between execution of the commands which occasionally comes in handy. See, e.g., vscode terminal: terminate process without prompt my answer there to terminating a process and answering Y and enter in one keychord from a texteditor or terminal which wouldn't work without the delay - for the process to terminate.



来源:https://stackoverflow.com/questions/54319412/create-new-untitled-file-and-set-language-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!