Json 宏扩展不同步运行命令

Json 宏扩展不同步运行命令,json,vscode-settings,Json,Vscode Settings,我想做一个快捷方式,可以在VScode行的72处插入当前日期。 我让光标先移动到72号位置,并使用扩展名获取当前日期。 但是,自定义扩展插件没有等待光标移动,日期显示在当前位置。 宏运行时似乎发生了异步。 这是我的密码 "addDate": [ "cursorLineEnd", {"command": "type", "args": {"text": "

我想做一个快捷方式,可以在VScode行的72处插入当前日期。 我让光标先移动到72号位置,并使用扩展名获取当前日期。 但是,自定义扩展插件没有等待光标移动,日期显示在当前位置。 宏运行时似乎发生了异步。 这是我的密码

"addDate": [
  "cursorLineEnd",
  {"command": "type", "args": {"text": "                                                                        "}},
  "cursorLineStart",
  {"command": "cursorMove", "args": {"to": "right", "by": "character", "value": 72}},
  {"command": "type", "args": {"text": "AD"}},
  "editor.action.trimTrailingWhitespace",
  {"command": "insertDateString.insertDate"},
]
{“command”:“insertDateString.insertDate”},
没有等待游标移动完成并直接工作。 有没有像“承诺…然后”或优先级设置这样的方法可以让PG按顺序运行?
谢谢

我建议使用宏命令。它正确地处理同步命令。因此,使用multi命令,将其放入您的设置中。josn:

 "multiCommand.commands": [

   {
      "command": "multiCommand.addDate",
      "sequence": [
        "cursorLineEnd",
        {
          "command": "type", 
          "args": {   "text": "                                                                        "
          }
        },
        "cursorLineStart",
        {"command": "cursorMove", "args": {"to": "right", "by": "character", "value": 72}},
        {"command": "type", "args": {"text": "AD"}},
        "editor.action.trimTrailingWhitespace",
        {"command": "insertDateString.insertDate"}
      ]
    }
  ]
然后,您的密钥绑定如下所示:

 {
    "key": "alt+d",                  // whatever you choose
    "command": "extension.multiCommand.execute",
    "args": { "command": "multiCommand.addDate" },
    // "when": "editorTextFocus"
  },

它的工作原理与预期一样。

我建议使用宏命令。它正确地处理同步命令。因此,使用multi命令,将其放入您的设置中。josn:

 "multiCommand.commands": [

   {
      "command": "multiCommand.addDate",
      "sequence": [
        "cursorLineEnd",
        {
          "command": "type", 
          "args": {   "text": "                                                                        "
          }
        },
        "cursorLineStart",
        {"command": "cursorMove", "args": {"to": "right", "by": "character", "value": 72}},
        {"command": "type", "args": {"text": "AD"}},
        "editor.action.trimTrailingWhitespace",
        {"command": "insertDateString.insertDate"}
      ]
    }
  ]
然后,您的密钥绑定如下所示:

 {
    "key": "alt+d",                  // whatever you choose
    "command": "extension.multiCommand.execute",
    "args": { "command": "multiCommand.addDate" },
    // "when": "editorTextFocus"
  },

它的工作原理与预期一样。

您使用的是什么宏扩展?还有更好的。你用的是什么宏扩展?有更好的。谢谢!我一直在使用的扩展,在,它工作得很好。谢谢!我一直在使用的扩展,在,它工作得很好。