html: Open extra newline between opening and closing HTML tags (#25130)
Closes #12064 It feels a bit strange to use `brackets` for this but it seems to work without unintended consequences from my testing so far. Release Notes: - N/A --------- Co-authored-by: Marshall Bowers <git@maxdeviant.com>
This commit is contained in:
parent
528da6eb26
commit
1429363218
7 changed files with 199 additions and 62 deletions
|
@ -918,7 +918,7 @@ pub struct Grammar {
|
|||
pub ts_language: tree_sitter::Language,
|
||||
pub(crate) error_query: Option<Query>,
|
||||
pub(crate) highlights_query: Option<Query>,
|
||||
pub(crate) brackets_config: Option<BracketConfig>,
|
||||
pub(crate) brackets_config: Option<BracketsConfig>,
|
||||
pub(crate) redactions_config: Option<RedactionConfig>,
|
||||
pub(crate) runnable_config: Option<RunnableConfig>,
|
||||
pub(crate) indents_config: Option<IndentConfig>,
|
||||
|
@ -1039,10 +1039,16 @@ struct InjectionPatternConfig {
|
|||
combined: bool,
|
||||
}
|
||||
|
||||
struct BracketConfig {
|
||||
struct BracketsConfig {
|
||||
query: Query,
|
||||
open_capture_ix: u32,
|
||||
close_capture_ix: u32,
|
||||
patterns: Vec<BracketsPatternConfig>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
struct BracketsPatternConfig {
|
||||
newline_only: bool,
|
||||
}
|
||||
|
||||
impl Language {
|
||||
|
@ -1284,11 +1290,24 @@ impl Language {
|
|||
("close", &mut close_capture_ix),
|
||||
],
|
||||
);
|
||||
let patterns = (0..query.pattern_count())
|
||||
.map(|ix| {
|
||||
let mut config = BracketsPatternConfig::default();
|
||||
for setting in query.property_settings(ix) {
|
||||
match setting.key.as_ref() {
|
||||
"newline.only" => config.newline_only = true,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
config
|
||||
})
|
||||
.collect();
|
||||
if let Some((open_capture_ix, close_capture_ix)) = open_capture_ix.zip(close_capture_ix) {
|
||||
grammar.brackets_config = Some(BracketConfig {
|
||||
grammar.brackets_config = Some(BracketsConfig {
|
||||
query,
|
||||
open_capture_ix,
|
||||
close_capture_ix,
|
||||
patterns,
|
||||
});
|
||||
}
|
||||
Ok(self)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue