最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

VS Code Extension API - bizzare javascript behaviour - Stack Overflow

programmeradmin4浏览0评论

I have a normal js file for vscode extension api. When debugging, js seems to be broken (I know, impossible). Here is my code ...

context.subscriptions.push(
  vscodemands.registerCommand("stickyBookmarks.toggleBookmark", 
    () => {
      const textEditor = vscode.window.activeTextEditor;
      if (!textEditor) return;

      const document   = textEditor.document;
      const lineNum    = document.lineCount-1;

      const textLine   = document.lineAt(lineNum-2);
      const lineRange  = textLine.range;

      const rgtChrIdx  = lineRange.end.character;
      const lftChrIdx  = rgtChrIdx-4;

      // debugger breakpoint here
      const lftPos     = new vscode.Position(lineNum, lftChrIdx);
      const rgtPos     = new vscode.Position(lineNum, rgtChrIdx);
      const chrRange   = new vscode.Range(lftPos, rgtPos);
      const text       = document.getText(chrRange);

      if(text === "\/\*\*\/") textEditor.edit(
        editBuilder => editBuilder.replace(chrRange, ""));
    }
  )
);

At the breakpoint rgtChrIdx == 14 and lftChrIdx == 0. I have tried a breakpoint on every line. Does anyone have any idea what is going on?

发布评论

评论列表(0)

  1. 暂无评论