Skip to content

Conversation

Traben-0
Copy link
Contributor

@Traben-0 Traben-0 commented Oct 3, 2025

Description

Sorry about it being so large, this pr should be MUCH EASIER to review commit by commit

Features:

  • adds a plugin settings screen
  • preprocessor fold regions
    • can optionally collapse inactive regions by default (based on preprocessor condition checks)
    • can optionally collapse all by default
  • preprocessor condition checking
    • now support chained checks e.g. //#if this && that
    • now support loader checks e.g. //#if FABRIC && !FORGE
    • now correctly checks conditions that need to be false, such as the #if/elseif's preceding an #else/elseif block being tested
  • preprocessor jump to file action
    • now also correctly moves you to the same caret position and scrolls to it
    • can now differentiate files based on the preprocessor conditions that apply at the caret position
    • can now optionally hide those differentiated results
    • can now press the down arrow from the search bar to navigate to the list (keyboard navigation streamlining)
  • can optionally highlight formatting/clarity problems such as:
    • #if directive not being indented further than it's containing preprocessor block
    • #else/elseif/endif directives not having a matching indent with their initial #if directive
  • adds an option to disable the //$$ insertion on new lines

Fixes:

  • fixed kotlin k2 mode not registering correctly and always ignoring the optional kotlin-plugin.xml, and thus no working kotlin file folding in k2
  • the condition changes fixed/improved PreprocessorNewLineHandler noticably
  • several bugs from the previous preprocessor condition checking, including the prevSibling iterating not correctly finding previous directives
  • correct version checking has replaced some logic that used mainVersion for all files, mainVersion is still a fallback if this fails

Related Issue(s)

Fixes #22
Fixes #20 but not the side note
Fixes #18
Fixes #15 to an extent

How to test

automatic default folding based on file version
in 1.12.2 version file
image

settings screen with default settings
image

differentiate jump to files based on conditions applied at caret
image

same but with non matches hidden
image

format highlighting
image
image
image

other changes arent really showable via screenshot, will require actual testing with k2 kotlin mode && various preprocessor conditions that didnt work before such as //#if MC>11600 && !FABRIC

Release Notes

- adds a plugin settings screen
- preprocessor fold regions
   - can optionally collapse inactive regions by default (based on preprocessor condition checks)
   - can optionally collapse all by default
- preprocessor condition checking
   - now support chained checks e.g. `//#if this && that`
   - now support loader checks e.g. `//#if FABRIC && !FORGE`
   - now correctly checks conditions that need to be false, such as the #if/elseif's preceding an #else/elseif block being tested
- preprocessor jump to file action
   - now also correctly moves you to the same caret position and scrolls to it
   - can now differentiate files based on the preprocessor conditions that apply at the caret position
   - can now optionally hide those differentiated results
   - can now press the down arrow from the search bar to navigate to the list (keyboard navigation streamlining)
- can optionally highlight formatting/clarity problems such as:
   - #if directive not being indented further than it's containing preprocessor block
   - #else/elseif/endif directives not having a matching indent with their initial #if directive 
- adds an option to disable the `//$$ ` insertion on new lines
- fixed kotlin k2 mode not registering correctly and always ignoring the optional kotlin-plugin.xml, and thus no working kotlin file folding in k2
- the condition changes fixed/improved `PreprocessorNewLineHandler` noticably
- several bugs from the previous preprocessor condition checking, including the `prevSibling` iterating not correctly finding previous directives
- correct version checking has replaced some logic that used `mainVersion` for all files, `mainVersion` is still a fallback if this fails

…eprocessorVersion` class

usages in later commits (this commit was cherry-picked after the fact)
usages in later commits (this commit was cherry-picked after the fact)
…ass for more generic use outside `PreprocessorNewLineHandler`

fixes:
- added loader condition parsing e.g. `//#if FABRIC`
- added parsing for multiple chained expressions  e.g. `//#if FABRIC && MC>=1`
- fixed the broken `.prevSibling` iterating that did not always properly navigate to previous directive Psi's

usages in later commits (this commit was cherry-picked after the fact)
…whether they met the preprocessor conditions at the caret position of the current file
- highlight if directives that are not further indented than their outer containing block
- highlight non directives & `//$$` that are not inline with their initial if directive
@Wyvest Wyvest merged commit 964e24e into Polyfrost:main Oct 3, 2025
2 of 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
2 participants