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

Conflicting instructions in sections for a given file #74

Open
mipo256 opened this issue Mar 1, 2025 · 7 comments
Open

Conflicting instructions in sections for a given file #74

mipo256 opened this issue Mar 1, 2025 · 7 comments
Assignees

Comments

@mipo256
Copy link
Member

mipo256 commented Mar 1, 2025

Consider that we have file, located in /some/dir/MyFile.java

And we have the following .editorconfig file:

root = true

[/some/dir/*.java]
end_of_line = cr

[/**/MyFile.{java,js}]
end_of_line = lf

This is a very simple example to demonstrate the problem. The problem essentially is that any file X, such as /some/dir/MyFile.java in our example, could be potentially matched by multiple sections. And those sections can (the spec correctly does not forbid it) have conflicting instructions, such as an example above.

What we need to do:

The spec must clarify what we require the implementation to do in such case.

@mipo256
Copy link
Member Author

mipo256 commented Mar 1, 2025

CC: @xuhdev @cxw42

What are your thoughts on this?

@SunsetTechuila
Copy link
Member

SunsetTechuila commented Mar 1, 2025

I wasn't asked, but I think this doesn't have to be a special case, it's enough to specify the order in which the sections are combined, as they can already be, and to state that a that a section can override options from the previous one.

@mipo256
Copy link
Member Author

mipo256 commented Mar 1, 2025

@SunsetTechuila Yeah, this is the very first thought that comes to mind, but I doubt it is extensible. We could've had 2 files, and both of them match to both sections. The problem is that we might want for one file to take settings from section A, and for the second file take settings from section B.

So although this solution is very simple, I do not think it is ideal.

@mipo256 mipo256 self-assigned this Mar 1, 2025
@xuhdev
Copy link
Member

xuhdev commented Mar 1, 2025

I wasn't asked, but I think this doesn't have to be a special case, it's enough to specify the order in which the sections are combined, as they can already be, and to state that a that a section can override options from the previous one.

I agree this is the intended behavior. The spec says:

Files are read top to bottom and the most recent rules found take precedence. If multiple EditorConfig files have matching sections, the rules from the closer EditorConfig file are read last, so pairs in closer files take precedence.

I think we just need to replace the word "rule" with "pair", which is defined in the spec.

@mipo256
Copy link
Member Author

mipo256 commented Mar 1, 2025

Okay, if we have stated this already in the doc, then, I guess, the solution proposed by @SunsetTechuila comes naturally

@SunsetTechuila
Copy link
Member

It's not a solution proposed by me, but by the spec) I read it once more after seeing your issue, but somehow missed that exact paragraph.

@mipo256
Copy link
Member Author

mipo256 commented Mar 1, 2025

@SunsetTechuila I agree, that is just a question of interpretation. In any case, thank you for pointing this out, I appreciate that 🤝

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

3 participants