-
Notifications
You must be signed in to change notification settings - Fork 53
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
Introduce findFilesGlob configuration. Allows to define where to look for the files. #69
base: master
Are you sure you want to change the base?
Conversation
src/utils.ts
Outdated
@@ -102,9 +102,20 @@ export const getFileIdRegexp = () => { | |||
|
|||
export const FILE_ID_REGEXP = getFileIdRegexp(); | |||
|
|||
export const getFileTypesSetting = () => { | |||
export const getFileSearchExpression = (): string => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about the naming getFileSearchExpression
. It could be changed to getFindFilesGlob
to make it more in sync with VS Code API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getFindFilesGlob
sounds better to me. Although we probably don't want to shadow the API in case this is what happens here (I don't fully get what you mean so might be talking nonsense).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, findFilesGlob
sounds better. I renamed:
getFilesSearchExpression
togetFindFilesGlob
searchGlob
tofindFilesGlob
This way it's consistent throughout the whole change.
I don't fully get what you mean so might be talking nonsense
The second sentence in my comment only meant that VS Code API decided to name the option for finding files getFindFilesGlob
. I think that it's good that we use the same naming if we don't have a particular reason to diverge.
@@ -102,9 +102,20 @@ export const getFileIdRegexp = () => { | |||
|
|||
export const FILE_ID_REGEXP = getFileIdRegexp(); | |||
|
|||
export const getFileTypesSetting = () => { | |||
export const getFileSearchExpression = (): string => { | |||
const configFileTypes: string[] = getConfiguration("fileTypes"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably either deprecate this search option or include it to package.json
and README.
package.json
Outdated
"description": "Regular extension used to find file IDs. First match of this regex in file contents, excluding [[links]], will be used as the file ID. This file ID can be used for wiki-style links." | ||
"description": "Regular expression used to find file IDs. First match of this regex in file contents, excluding [[links]], will be used as the file ID. This file ID can be used for wiki-style links." | ||
}, | ||
"markdown-links.searchGlob" : { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once we release this PR, searchGlob
is going to be a part of the public interface and very hard to rename in the future. I'm open to any other names like fileSearchGlob
findFilesExpression
or any cobination of the search
, find
, files
, expression
, glob
..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good idea. Appreciate a lot the fact that you consider it already at this point!
I think searchGlob
is ok. Maybe it would be more future proof to specify what is the search we are doing here. Maybe fileDiscoveryGlob
presents it better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went with findFilesGlob
for consistency. Let me know if that's ok :)
Will this allow sub-directories to be excluded from the search? |
@Craskermasker in some limited cases. This feature is more for defining where your notes are than where they aren't. You can see more details in the VS Code API documentation for There is an |
@tchayen I addressed your feedback and tested the change locally (it still works). Please let me know if there's anything else I can do 👍 |
Closes #63
This PR introduces a new configuration option,
searchGlob
. The configuration option isnull
by default and doesn't interfere with the current logic.If set, the option overrides the expression generated from
fileTypes
configuration. If thefileTypes
configuration has been set, we'll warn the user:This PR contains 3 commits:
I tried to write tests, but I wasn't able to run them since this extension uses
webpack
rather than plaintsc
.