Typos ignores files in `.gitignore`, even when they are force-tracked in git
Crown0815 opened this issue · 6 comments
I have a situation where a typo in a .png
file's name was corrected in the reference of a .md
file, but the name of the .png
file itself was not corrected.
folder
├ my_tipo.png
└ my_docu.md
With the content of my_docu.md
:
[image](./mytipo.png)
now typos
correctly fixes the typo in my_docu.md
but does not fix the file name of my_tipo.png
which breaks the link.
Are PNGs not checked in general? Is it possible to have them checked?
I tried adding this to my _typos.toml
but it did nothing:
[type.images]
extend-glob = ["*.png"]
check-file = false
If you run typos --identifiers my_docu.md
you will likely see that mytipo
is not listed for my_docu.md
. Without testing it, my guess is that this is being caught by our URL filter (we can't fix a website...)
As for
[type.images]
extend-glob = ["*.png"]
check-file = false
That is saying to not check the content of png
files but check-filename
is likely still true so the file name will be corrected. This has no affect when a file path ending in png
is found in a file.
Sorry, my bad, I tried to create a minimal example but that actually hid the actual issue I am facing:
So the concrete situation looks like this:
folder
├ OptionsWindwoWithParametersExample.png
└ Architecture.md
and Architecture.md
contains
![Options window with highlighted ModificationParameter UI representations](OptionsWindwoWithParametersExample.png)
Now running typos
on that folder produces the following output:
error: `Windwo` should be `Window`
--> ./Architecture.md:1:84
|
1 | ![Options window with highlighted ModificationParameter UI representations](OptionsWindwoWithParametersExample.png)
| ^^^^^^
|
For some reason the typo is detected in the Architecture.md
file, but not in the *.png
.
The part where things get weird for me is that I tried to isolate the problem by copying the folder (which is part of a much large project) into a separate directory from the rest of the project and there the output is:
error: `Windwo` should be `Window`
--> ./OptionsWindwoWithParametersExample.png:8
error: `Windwo` should be `Window`
--> ./Architecture.md:1:84
|
1 | ![Options window with highlighted ModificationParameter UI representations](OptionsWindwoWithParametersExample.png)
| ^^^^^^
|
which is exactly what I would expect.
In both cases I ran typos with the folder being the working directory and no _typos.toml
configuration file.
So the file name is not being checked when it is expected to be ... sometimes and why it hits in some cases but not others is not clear which makes providing a reproduction case hard. Is that correct?
Some useful tools:
Debug flags
--files Debug: Print each file that would be spellchecked
--file-types Debug: Print each file's type
--identifiers Debug: Print each identifier that would be spellchecked
--words Debug: Print each word that would be spellchecked
--dump-config <DUMP_CONFIG> Write the current configuration to file with `-` for stdout
Running with higher verbosity logging (-vvv
... I never remember how many but the more, the merrier).
I found the issue. PNGs are in our .gitignore
file. I removed PNGs from the .gitignore
and now the file is being detected.
The file is actually tracked by git, because it is an "exception" to the "no-PNGs" rule.
Is this expected behavior?
I assume this is a case where you ignored all of the files but you forced git to track this file, rather than modify your .gitignore
to allow it?
It is expected that we respect .gitignore
and,. without expensive git operations, we have no way to know that you made that exception. I would generally recommend handling this in your .gitignore
, rather than forcing git.
I understand. Makes perfect sense. Thank you very much for your help.