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

Why does the tests have arbitrary key=value value pairs #50

Closed
mstruebing opened this issue Jan 15, 2023 · 4 comments
Closed

Why does the tests have arbitrary key=value value pairs #50

mstruebing opened this issue Jan 15, 2023 · 4 comments
Labels

Comments

@mstruebing
Copy link

I'm currently implementing a rust version of the core and when running and digging into the test suite I see that
mostly key=value is used.
Whereas editorconfig specification specifies which key-value pairs are allowed.

Is there some reason for this?
Why don't we use options from the specification? That means every core needs to handle key-value pairs (key=value) which are not really defined in the spec.

@cxw42
Copy link
Member

cxw42 commented Jan 16, 2023

Yes, all cores need to handle all keys, even those not defined. There are many more custom keys in the wild than defined keys, as far as I can tell from the discussions I've seen!

However, I note this is not expressly called out in https://spec.editorconfig.org/#supported-pairs. I will open a PR clarifying that.

Edit as for why --- I think just convenience :) . In some cases, we use different keys or values to make sure that the core is reading from the correct section of a .editorconfig file.

@cxw42
Copy link
Member

cxw42 commented Jan 16, 2023

I took a quick look at https://github.com/mstruebing/editorconfig-core-rust/blob/main/src/main.rs#L45. Cores should not have any specific knowledge of which keys or values are relevant. That knowledge lives in the plugin, which maps key/value pairs to a particular editor's settings. Therefore, your core does not need indent_style, indent_size, ... .

The core is just a text processor: it reads text files, looks for glob matches, and pulls out key-value pairs. Its ultimate output is a set of key-value pairs that relate to a specific file, and that set is what the core tests are checking for. Here's an example on my system:

/home/cxw/proj/editorconfig-vim$ ./tests/core/editorconfig /home/cxw/proj/editorconfig-vim/foo.ps1
max_line_length=80
charset=utf-8
end_of_line=crlf

The core looked through the .editorconfig files and found that foo.ps1 had three key-value pairs (max_line_length, charset, and end_of_line). It reported those out, and then its job was done.

I hope this helps! I am going to close this issue, but feel free to ask further questions if you need assistance!

(For what it's worth, I implemented the Vimscript core by translating the Python core :) . )

@cxw42 cxw42 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 16, 2023
@cxw42
Copy link
Member

cxw42 commented Jan 16, 2023

Here's an example of a key not in the spec: dotnet/roslyn#33012 is using the custom property file_header_template.

@xuhdev
Copy link
Member

xuhdev commented Jan 16, 2023

As posted in editorconfig/specification#37 (comment):

The reasons are:

  • We allow some editors to put in extra non-standard key-value pairs.
  • For any further development of new standard key-value pairs, a lot of times only plugins need to be updated. In this way we avoid the need to tie core libraries to the change in standard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants