为什么 GitHub 的 Atom 自动完成建议符号从末尾截断一个字符?

Why is GitHub's Atom autocomplete suggesting symbols with one character truncated from the end?

我不确定 why/when 这是开始的,但我经常收到关于我的代码中存在的值的自动建议,但缺少最后一个字母。不是个例,经常发生

我是运行版本1.6.0

这是我的包裹清单:

Built-in Atom packages (89)
├── about@1.3.0
├── archive-view@0.61.0
├── atom-dark-syntax@0.27.0
├── atom-dark-ui@0.51.0
├── atom-light-syntax@0.28.0
├── atom-light-ui@0.43.0
├── autocomplete-atom-api@0.10.0
├── autocomplete-css@0.11.0
├── autocomplete-html@0.7.2
├── autocomplete-plus@2.25.0
├── autocomplete-snippets@1.10.0
├── autoflow@0.27.0
├── autosave@0.23.0
├── background-tips@0.26.0
├── base16-tomorrow-dark-theme@1.1.0
├── base16-tomorrow-light-theme@1.1.1
├── bookmarks@0.38.2
├── bracket-matcher@0.79.0
├── command-palette@0.38.0
├── deprecation-cop@0.54.0
├── dev-live-reload@0.47.0
├── encoding-selector@0.21.0
├── exception-reporting@0.37.0
├── find-and-replace@0.197.4
├── fuzzy-finder@0.94.0
├── git-diff@0.57.0
├── go-to-line@0.30.0
├── grammar-selector@0.48.0
├── image-view@0.56.0
├── incompatible-packages@0.25.0
├── keybinding-resolver@0.33.0
├── language-c@0.51.1
├── language-clojure@0.19.1
├── language-coffee-script@0.46.0
├── language-csharp@0.11.0
├── language-css@0.36.0
├── language-gfm@0.84.0
├── language-git@0.12.1
├── language-go@0.42.0
├── language-html@0.44.0
├── language-hyperlink@0.16.0
├── language-java@0.17.0
├── language-javascript@0.110.0
├── language-json@0.17.4
├── language-less@0.29.0
├── language-make@0.21.0
├── language-mustache@0.13.0
├── language-objective-c@0.15.1
├── language-perl@0.32.0
├── language-php@0.37.0
├── language-property-list@0.8.0
├── language-python@0.43.0
├── language-ruby@0.68.0
├── language-ruby-on-rails@0.25.0
├── language-sass@0.45.0
├── language-shellscript@0.21.0
├── language-source@0.9.0
├── language-sql@0.20.0
├── language-text@0.7.0
├── language-todo@0.27.0
├── language-toml@0.18.0
├── language-xml@0.34.2
├── language-yaml@0.25.1
├── line-ending-selector@0.3.0
├── link@0.31.0
├── markdown-preview@0.157.2
├── metrics@0.53.1
├── notifications@0.62.1
├── one-dark-syntax@1.2.0
├── one-dark-ui@1.1.9
├── one-light-syntax@1.2.0
├── one-light-ui@1.1.9
├── open-on-github@0.41.0
├── package-generator@0.41.0
├── settings-view@0.232.3
├── snippets@1.0.1
├── solarized-dark-syntax@1.0.0
├── solarized-light-syntax@1.0.0
├── spell-check@0.65.0
├── status-bar@0.83.0
├── styleguide@0.45.1
├── symbols-view@0.110.1
├── tabs@0.91.3
├── timecop@0.33.0
├── tree-view@0.203.2
├── update-package-dependencies@0.10.0
├── welcome@0.33.0
├── whitespace@0.32.1
└── wrap-guide@0.38.1

/Users/me/.atom/packages (26)
├── Stylus@1.0.0
├── activate-power-mode@0.4.1
├── atom-beautify@0.28.24
├── atom-jade@0.3.0
├── atom-material-ui@0.8.0
├── auto-indent@0.5.0
├── autoclose-html@0.22.0
├── emmet@2.4.1
├── file-icons@1.6.19
├── git-diff-details@0.20.0
├── highlight-selected@0.11.2
├── idiomatic-dark-syntax@0.1.3
├── language-cjsx@0.3.0
├── language-javascript-jsx@0.3.7
├── linter@1.11.3
├── linter-coffeelint@1.1.2
├── linter-eslint@5.2.6
├── merge-conflicts@1.3.2
├── pigments@0.26.0
├── predawn-ui@1.0.2
├── pretty-json@0.4.1
├── react@0.14.1
├── react-snippets@0.1.4
├── seti-ui@0.8.1
├── spacegray-dark-neue-ui@1.4.0
└── spacegray-dark-ui@0.12.0

事实证明这是 language-cjsx 包中的一个缺陷。如果您使用 CtrlAltI 打开 Chrome 开发人员工具并检查函数名称由语法标识的标记在每个函数名称的最后一个字符周围都有一个不必要的 span 元素。

我已经设法通过 removing the mapping between one of the capture groups and the grammar class. Whilst this works, a more elegant solution from Víctor Martínez is available that incorporates all of the recent changes from the CoffeeScript grammar package.

在我的 fork 中解决了这个问题

如果您想对此进行测试,可以按照以下过程进行:

  1. 卸载 language-cjsx 软件包的现有版本。
  2. language-cjsx 的上述两个分支之一克隆到已知目录。
  3. 运行 apm link <path-to-directory> 将包符号链接到 Atom 的包目录。
  4. 使用 CtrlAltR.
  5. 重新启动 Atom

最后说明:Víctor Martínez has subsequently noted that he is currently using orktes/atom-react 获得基于 CJSX 的解决方案的语法突出显示。