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

fix: strings can't start with "?" #15

Merged
merged 1 commit into from
Jan 4, 2025

Conversation

gerblesh
Copy link
Contributor

@gerblesh gerblesh commented Jan 3, 2025

This should fix the highlighting of "?" for optional filepaths in the config-file directive

@gerblesh
Copy link
Contributor Author

gerblesh commented Jan 3, 2025

This starts to cause issues with config keys such as custom-shader and gtk-custom-css. We could either add these specifically to the grammar or have path_value as a normal value type.

@bezhermoso
Copy link
Owner

Can you please add some test cases?

@bezhermoso
Copy link
Owner

============================
Basic Directive - "?" Prefix
============================

custom-shader = "?weird/path/to/shader"
custom-shader = ?weird/path/to/shader

---

(document 
 (directive 
  (basic_directive
   (property)
   (value
    (string))))
 (directive 
  (basic_directive
   (property)
   (value
    (string)))))

^^^ is there a problem in the way this is parsed? According to the docs, only config-file supports paths that may not exist. Tested specifying an non-existent shader file and Ghostty seems just fine.

@gerblesh
Copy link
Contributor Author

gerblesh commented Jan 3, 2025

============================
Basic Directive - "?" Prefix
============================

custom-shader = "?weird/path/to/shader"
custom-shader = ?weird/path/to/shader

---

(document 
 (directive 
  (basic_directive
   (property)
   (value
    (string))))
 (directive 
  (basic_directive
   (property)
   (value
    (string)))))

^^^ is there a problem in the way this is parsed? According to the docs, only config-file supports paths that may not exist. Tested specifying an non-existent shader file and Ghostty seems just fine.

hmm, that's odd. It seems like the ? is ignored for everything that accepts path input. Ghostty doesn't seem to be sending warnings when the ? isn't there. Is it worth supporting highlighting the ? then?

@gerblesh
Copy link
Contributor Author

gerblesh commented Jan 3, 2025

Could also be a bug, I'm running an unstable git version currently

@bezhermoso
Copy link
Owner

Until it's officially documented that those properties treat a leading ? as a prefix, I think it's premature to add it to the grammar.

Introducing it in the future doesn't seem like it would be a breaking change as it wouldn't introduce another level to the tree in a way that existing queries might break.

@gerblesh
Copy link
Contributor Author

gerblesh commented Jan 3, 2025

image
Seems like the usage of the ? applies to every directive that accepts some form of filepath(?), I'm inclined to just add the gtk-custom-css and custom-shader directives directly in the grammar

@bezhermoso
Copy link
Owner

@gerblesh We can generalize it into a path_directive or something.

@gerblesh
Copy link
Contributor Author

gerblesh commented Jan 4, 2025

seems like it's also an issue upstream: ghostty-org/ghostty#4509

@gerblesh
Copy link
Contributor Author

gerblesh commented Jan 4, 2025

Added some extra tests and squashed the commits, should be able to merge now

Copy link
Owner

@bezhermoso bezhermoso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@bezhermoso bezhermoso merged commit c4281fd into bezhermoso:main Jan 4, 2025
3 checks passed
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

Successfully merging this pull request may close these issues.

2 participants