Commit 3982a8c
Fix format on save ignored directories path matching logic (#325)
* fix(plugin): resolve ignored directories never matching due to trailing slash
Fixes a bug introduced in #191
Directory paths with a trailing "/" (e.g. "addons/") would produce
a trailing empty string when split on "/", which could never match
a real path segment. This silently broke the ignore rule for any
entry with a trailing slash.
This fix trims the trailing "/" before splitting.
* fix(plugin): resolve out-of-bounds access when ignored directory is deeper than script path
Fixes a bug introduced in #191
The matching loop indexed script_path_parts[i] using the length of
directory_parts, without checking that directory_parts wasn't longer.
If an ignored directory's path has more segments than the script's
path, and every one of those extra segments follows a full match of
the script's path, the loop runs past the end of script_path_parts.
Example: script at "res://addons/foo.gd" (script_path_parts =
["addons", "foo.gd"]) checked against ignored directory
"addons/foo.gd/bar" (directory_parts = ["addons", "foo.gd", "bar"]).
The first two segments match, then the loop tries to read
script_path_parts[2], which doesn't exist.
Skip directories that have more segments than the script path, since
they can never match as a prefix.
* fix(plugin): skip and warn on blank format on save ignored directories entries
Fixes a bug introduced in #191
An ignored directory entry that is blank, "res://", or just "/" would
normalize to an empty string. Splitting that on "/" produces [""],
which could be compared against script path segments in unintended
ways instead of being treated as an invalid entry.
Skip these entries and push a warning so users know the entry has no usable path and needs to be removed or corrected.
Also warns the user that if the intention was to ignore the whole project that this is not supported here and they need to turn of format on save instead.
* fix(plugin): warn on format on save ignored directories entries that duplicate an earlier entry after normalization
Fixes a bug introduced in #191
The Format on Save Ignored Directories list was not checked for entries that normalize
to the same path despite being written differently (e.g. "res://addons" and "addons/").
This could let redundant entries sit in the list unnoticed.
Track each normalized entry as it's validated, and if a later entry normalizes to the same as one already seen,
skip it and push a warning naming both the duplicate and the original entry it conflicts with.
* refactor: trim comments, rename variables
---------
Co-authored-by: Nathan Lovato <12694995+NathanLovato@users.noreply.github.com>1 parent b7e122c commit 3982a8c
1 file changed
Lines changed: 34 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
| 176 | + | |
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
191 | | - | |
| 191 | + | |
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
| |||
347 | 347 | | |
348 | 348 | | |
349 | 349 | | |
350 | | - | |
351 | | - | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
352 | 373 | | |
353 | | - | |
| 374 | + | |
| 375 | + | |
354 | 376 | | |
355 | | - | |
356 | | - | |
357 | | - | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
358 | 382 | | |
359 | 383 | | |
360 | | - | |
361 | | - | |
| 384 | + | |
| 385 | + | |
362 | 386 | | |
363 | 387 | | |
364 | 388 | | |
| |||
0 commit comments