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

Typos ignores files in .gitignore, even when they are force-tracked in git #909

Closed
Crown0815 opened this issue Jan 18, 2024 · 6 comments
Closed

Comments

@Crown0815
Copy link

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
@Crown0815 Crown0815 changed the title Check file names of non-text files Check and fix file names of non-text files Jan 18, 2024
@epage
Copy link
Collaborator

epage commented Jan 18, 2024

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.

@Crown0815
Copy link
Author

Crown0815 commented Jan 20, 2024

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.

@Crown0815 Crown0815 changed the title Check and fix file names of non-text files PNG file not renamed Jan 20, 2024
@epage
Copy link
Collaborator

epage commented Jan 22, 2024

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).

@Crown0815
Copy link
Author

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?

@epage
Copy link
Collaborator

epage commented Jan 23, 2024

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.

@epage epage changed the title PNG file not renamed Typos ignores files in .gitignore, even when they are force-tracked in git Jan 23, 2024
@Crown0815
Copy link
Author

I understand. Makes perfect sense. Thank you very much for your help.

epage added a commit that referenced this issue Jan 23, 2024
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

2 participants