Module: Canopus::Workspace::EditorConfigurable
- Defined in:
- lib/canopus/workspace/editor_configurable.rb
Constant Summary collapse
- EDITORCONFIG_MAX_BYTES =
64 * 1024
- EDITORCONFIG_CACHE_LIMIT =
1_024
Instance Method Summary collapse
- #invalidate_editorconfig ⇒ Object
- #prepare_editorconfig_save(buffer, path) ⇒ Object
- #settings_for_editor(editor) ⇒ Object
-
#settings_for_path(path, language: nil) ⇒ Object
Return settings with the file's EditorConfig properties inserted before the project settings layer.
Instance Method Details
#invalidate_editorconfig ⇒ Object
21 22 23 24 |
# File 'lib/canopus/workspace/editor_configurable.rb', line 21 def invalidate_editorconfig @editorconfig_cache&.clear nil end |
#prepare_editorconfig_save(buffer, path) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/canopus/workspace/editor_configurable.rb', line 26 def prepare_editorconfig_save(buffer, path) return if buffer.read_only values = settings_for_path(path) buffer.trim_trailing_whitespace if values["trim_trailing_whitespace"] buffer.ensure_final_newline if values["insert_final_newline"] end |
#settings_for_editor(editor) ⇒ Object
17 18 19 |
# File 'lib/canopus/workspace/editor_configurable.rb', line 17 def settings_for_editor(editor) settings_for_path(editor.buffer.path, language: editor.language_document.definition.name) end |
#settings_for_path(path, language: nil) ⇒ Object
Return settings with the file's EditorConfig properties inserted before the project settings layer.
12 13 14 15 |
# File 'lib/canopus/workspace/editor_configurable.rb', line 12 def settings_for_path(path, language: nil) settings = editorconfig_settings(path) language ? settings.for_language(language) : settings end |