New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tree-Sitter: Invalid scope detected for empty JavaScript lines #17942

Closed
robertrossmann opened this Issue Aug 29, 2018 · 3 comments

Comments

Projects
None yet
4 participants
@robertrossmann

robertrossmann commented Aug 29, 2018

Prerequisites

Description

With Tree-Sitter enabled, inside a JavaScript file, the scope is reported as * if the cursor is placed on an empty line. This causes JavaScript code snippets to not work at all.

As soon as I place the cursor on any piece of code the scope is properly reported as being source.js + whatever syntax node is currently under the cursor.

Steps to Reproduce

  1. Enable Tree-Sitter parsers
  2. Create a new, empty JavaScript file or open an existing JS file and place the cursor on an empty line (ie. the last line)
  3. Log the cursor's scope
  4. Observe scope being reported as just * instead of source.js

Expected behavior: Scope is always reported as source.js regardless of whether or not there is a syntax node under the cursor

Actual behavior: Scope is reported as * when there is no syntax node under the cursor

Reproduces how often: All the time, for JavaScript files only (tested with Makefile, .json, .yaml, .sql, scopes work correctly here)

Versions

Atom    : 1.32.0-nightly3
Electron: 2.0.7
Chrome  : 61.0.3163.100
Node    : 8.9.3

Additional Information

I think this started happening sometime around 1.31.0-nightly6, not sure precisely when.

Obligatory screenshot with the scopes Atom reported as I tested it with various files.

scopes

@robertrossmann robertrossmann changed the title from Tree-Sitter: Invalid scope detected for empty JavaScript files to Tree-Sitter: Invalid scope detected for empty JavaScript lines Aug 29, 2018

@Ben3eeE Ben3eeE added the tree-sitter label Aug 29, 2018

@thomasjo

This comment has been minimized.

Show comment
Hide comment
@thomasjo

thomasjo Aug 29, 2018

Member

Just a minor correction here to avoid any confusion for whomever decides to tackle this issue; the cursor scope is not being reported as * by Tree-sitter. The * is simply a Markdown rendering artifact caused by producing an unordered list item with no body. In other words, we're only producing an asterisk because the scope reported by Tree-sitter (or possibly something in Atom core) is blank.

For reference:

  • showCursorScope = (descriptor, notificationManager) ->
    list = descriptor.scopes.toString().split(',')
    list = list.map (item) -> "* #{item}"
    content = "Scopes at Cursor\n#{list.join('\n')}"
    notificationManager.addInfo(content, dismissable: true)
  • atom/src/text-editor.js

    Lines 3880 to 3882 in bc00369

    getCursorScope () {
    return this.getLastCursor().getScopeDescriptor()
    }
Member

thomasjo commented Aug 29, 2018

Just a minor correction here to avoid any confusion for whomever decides to tackle this issue; the cursor scope is not being reported as * by Tree-sitter. The * is simply a Markdown rendering artifact caused by producing an unordered list item with no body. In other words, we're only producing an asterisk because the scope reported by Tree-sitter (or possibly something in Atom core) is blank.

For reference:

  • showCursorScope = (descriptor, notificationManager) ->
    list = descriptor.scopes.toString().split(',')
    list = list.map (item) -> "* #{item}"
    content = "Scopes at Cursor\n#{list.join('\n')}"
    notificationManager.addInfo(content, dismissable: true)
  • atom/src/text-editor.js

    Lines 3880 to 3882 in bc00369

    getCursorScope () {
    return this.getLastCursor().getScopeDescriptor()
    }
@maxbrunsfeld

This comment has been minimized.

Show comment
Hide comment
@maxbrunsfeld

maxbrunsfeld Aug 29, 2018

Contributor

Thanks for the reports @robertrossmann and @thomasjo. And thanks so much for using nightly! This bug is currently fixed in #17879, which hopefully will land soon.

Contributor

maxbrunsfeld commented Aug 29, 2018

Thanks for the reports @robertrossmann and @thomasjo. And thanks so much for using nightly! This bug is currently fixed in #17879, which hopefully will land soon.

@maxbrunsfeld

This comment has been minimized.

Show comment
Hide comment
@maxbrunsfeld

maxbrunsfeld Aug 30, 2018

Contributor

Actually, we're going to ship the fix before that PR lands. It'll go out in 1.31.0-beta1.

Contributor

maxbrunsfeld commented Aug 30, 2018

Actually, we're going to ship the fix before that PR lands. It'll go out in 1.31.0-beta1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment