Skip to content
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

Transforming symbols breaks implied global-definition tests using @@@ definition "transformed-symbol" #6596

Open
jrappen opened this issue Jan 16, 2025 · 0 comments

Comments

@jrappen
Copy link
Contributor

jrappen commented Jan 16, 2025

Description of the bug

When defining symbols and setting up automated syntax tests for them, things (currently) work as expected. Adding symbol transformation partially breaks tests.

Implied local-definition seems to work, implied global-definition does not, when using @@@ definition "transformed-symbol" in syntax tests.

Steps to reproduce

Transform symbols, as an example we use JSON.

<!-- Packages/JSON/Symbol List - Top Level Keys.tmPreferences -->

<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
    <!--
        If the JSON file contains an object,
        add its top-level keys as symbols to the index.

        Transform "key" -> key.

        Exclude keys of objects within an object.
        Exclude keys of objects within a list.
    -->
    <key>scope</key>
    <string><![CDATA[source.json meta.mapping.key - (meta.mapping.value meta.mapping.key | meta.sequence.list meta.mapping.key)]]></string>
    <key>settings</key>
    <dict>
        <key>showInSymbolList</key>
        <string>1</string>
        <key>symbolTransformation</key>
        <string><![CDATA[s/^["']|["']$//g;]]></string>
        <key>showInIndexedSymbolList</key>
        <string>1</string>
        <key>symbolIndexTransformation</key>
        <string><![CDATA[s/^["']|["']$//g;]]></string>
    </dict>
</dict>
</plist>

To quickly test this, use the JSON rewrite for sublimehq/Packages#3097 found at https://github.com/jrappen/sublime-json/ with the following changes:

image

Expected behavior

Top-level keys of a JSON object should here be added to the index even after transformation.

Actual behavior

When adding symbol transformation, previously working syntax tests break.

The symbol "key-one" in the test file is transformed to key-one and we need to add it quoted to the test line in the syntax_test_* file.

image

Compare the docs at https://www.sublimetext.com/docs/syntax.html#testing:

image

The test binary reports the following:

image

We see here that:

  • Even though a global and a local symbol are tested for via definition, the actual test only shows local-definition being tested, not definition as stated in the line of the syntax test file which implies that both global-definition and local-definition are included in the test.
  • The symbol was correctly transformed.
image

We see here that:

  • The test location is wrong. The test should be "key-one" in line 6 (the symbol before the transformation), but only tests key-one in line 6 (the symbol after the transformation).
  • The (above seemingly ignored) global-definition is now tested for, but in the wrong location.
  • The symbol was correctly transformed.

Compare the following from the two images above:

image

Sublime Text build number

4191

Operating system & version

any

(Linux) Desktop environment and/or window manager

any

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant