cspell icon indicating copy to clipboard operation
cspell copied to clipboard

Feat: Add config option `stopConfigSearchAt` to `CSpellSettings`

Open Jason3S opened this issue 6 months ago • 2 comments

Problem

When the spell checker find a file to spell check, it also searches for the nearest CSpell config file. The current --stop-config-search-at command line option is only applied to the initial scan.

For example, it will keep searching up even though you give it stop dirs.

Example file structure:

cspell.json -> { "flagWords": ["my_flag_word"] }
cwd/
  test.cspell.json -> { "words": ["my_flag_word"] }
  test.txt -> Contains my_flag_word
cwd/$ cpsell -c test.cspell.json --stop-config-search-at=. *.txt

This will fail.

Originally posted by @Jason3S in https://github.com/streetsidesoftware/cspell/issues/7440#issuecomment-2956676239

Solution

Add config option stopConfigSearchAt to CSpellSettings

stopConfigSearchAt?: FsPath | FsPath[]; 

Like dictionaryDefinition.path it needs to be resolved relative to the config file.

Jason3S avatar Jun 11 '25 05:06 Jason3S

Useful to group it with noConfigSearch

https://github.com/streetsidesoftware/cspell/blob/4e7e951d885b65470eb24cbf9d6fefe5e1440e27/packages/cspell-types/src/CSpellSettingsDef.ts#L105

Jason3S avatar Jun 11 '25 05:06 Jason3S

Hello @Jason3S,

I was able to pass the stopConfigSearchAt field into CSpellUserSettings through cspellSettingsFromCliOptions in the LintRequest class.

We already have a mechanism for handling stopConfigSearchAt, is there an existing hook or integration point, like we have for noConfigSearch, where this is expected to plug in? I'm trying to figure out the work that needs to be done.

Thanks!

thebolarin avatar Jul 30 '25 10:07 thebolarin