weixin_39939665
weixin_39939665
2020-12-07 08:00

F12 go-to-definition is broken

~~Go-to-def is Ctrl+T,Ctrl+D. Go to declaration doesn't even have a well-defined concept in our language. Let's just make the two equivalent.~~

Never mind, it seems that the keybinding is go-to-defintion, but it is not working correctly.

From parser.ts

 TypeScript
module ts {
    var nodeConstructors = new Array<new> Node>(SyntaxKind.Count);
    /*  */ export var parseTime = 0;

    export function getNodeConstructor(kind: SyntaxKind): new () => Node {
        return nodeConstructors[kind] || (nodeConstructors[kind] = objectAllocator.getNodeConstructor(kind));
    }
</new>

If you try F12 on Node, it will only work if types.ts is open.

If you try F12 on nodeConstructors, kind, SyntaxKind, or objectAllocator, nothing happens (e.g."Unable to find nodeConstructors"), even if types.ts is open.

If you try F12 on getNodeConstructor of objectAllocator.getNodeConstructor, it takes you to the wrong place (i.e. it takes you to the above function definition, instead of ObjectAllocator in core.ts

Keep in mind, Ctrl+T, Ctrl+D works for all of these

该提问来源于开源项目:microsoft/TypeScript-Sublime-Plugin

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

4条回答

  • weixin_39557813 weixin_39557813 5月前

    See other F12 issue. This is Sublime goto_definition, which is syntax-based. Daniel, sounds like you would support binding F12 to the TypeScript goto def.

    点赞 评论 复制链接分享
  • weixin_39939665 weixin_39939665 5月前

    Yes, so long as it doesn't break F12 for other file types, we should definitely be using our go-to-def for TypeScript files.

    (Just to document, the other F12 issue is #40.)

    点赞 评论 复制链接分享
  • weixin_39557813 weixin_39557813 5月前

    Commit 6f50d69 binds F12 to TypeScript go to definition only in TypeScript files.

    点赞 评论 复制链接分享
  • weixin_39939665 weixin_39939665 5月前

    Awesome! Thanks Steve! :+1:

    点赞 评论 复制链接分享

相关推荐