Compare commits

...

7 Commits

Author SHA1 Message Date
Ivan Tham 13d897c1b1
Merge b8d067015a into 362e97e927 2025-06-16 10:17:25 -05:00
Michael Davis 362e97e927
Update tree-house to v0.3.0
This release contains some fixes to highlight ordering which could cause
panics in the markdown component for highlights arriving out of order.
2025-06-16 10:27:19 -04:00
Michael Davis ba54b6afe4
LSP: Short-circuit documentColors request for no servers
This fixes a deadlock when starting Helix with very many files, like
`hx runtime/queries/*/*.scm`. The tree-sitter query files don't have
an active language server on my machine and yet we were spawning a tokio
task to collect documentColors responses. We can skip that entirely.
Further debugging is needed to figure out why this lead to a deadlock
previously.
2025-06-16 09:42:48 -04:00
Tatesa Uradnik 837627dd8a
feat: allow moving nonexistent file (#13748) 2025-06-16 08:19:28 -05:00
CalebLarsen 1246549afd
Fix: update c++ highlights (#13772) 2025-06-16 08:04:22 -05:00
uncenter ada8004ea5
Highlight HTML entities (#13753) 2025-06-16 08:03:02 -05:00
Ivan Tham b8d067015a Word movement select from first range
3w currently selects the 3rd word, this changes the behavior to select
all 3 words rather than just the last.
2025-06-13 01:13:13 +08:00
10 changed files with 140 additions and 34 deletions

4
Cargo.lock generated
View File

@ -2810,9 +2810,9 @@ checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801"
[[package]]
name = "tree-house"
version = "0.2.0"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "679e3296e503901cd9f6e116be5a43a9270222215bf6c78b4b1f4af5c3dcc62d"
checksum = "d00ea55222392f171ae004dd13b62edd09d995633abf0c13406a8df3547fb999"
dependencies = [
"arc-swap",
"hashbrown 0.15.4",

View File

@ -37,7 +37,7 @@ package.helix-tui.opt-level = 2
package.helix-term.opt-level = 2
[workspace.dependencies]
tree-house = { version = "0.2.0", default-features = false }
tree-house = { version = "0.3.0", default-features = false }
nucleo = "0.5.0"
slotmap = "1.0.7"
thiserror = "2.0"

View File

@ -251,14 +251,20 @@ fn word_move(slice: RopeSlice, range: Range, count: usize, target: WordMotionTar
// Do the main work.
let mut range = start_range;
let mut first_range = None;
for _ in 0..count {
let next_range = slice.chars_at(range.head).range_to_target(target, range);
if range == next_range {
break;
}
range = next_range;
if first_range.is_none() {
first_range = Some(range);
}
range
}
let first_range = first_range.unwrap_or(range);
let last_range = range;
Range::new(first_range.anchor, last_range.head)
}
pub fn move_prev_paragraph(
@ -1042,11 +1048,11 @@ mod test {
]),
("Multiple motions at once resolve correctly",
vec![
(3, Range::new(0, 0), Range::new(17, 20)),
(3, Range::new(0, 0), Range::new(0, 20)),
]),
("Excessive motions are performed partially",
vec![
(999, Range::new(0, 0), Range::new(32, 41)),
(999, Range::new(0, 0), Range::new(0, 41)),
]),
("", // Edge case of moving forward in empty string
vec![
@ -1298,11 +1304,11 @@ mod test {
]),
("Multiple motions at once resolve correctly",
vec![
(3, Range::new(0, 0), Range::new(17, 20)),
(3, Range::new(0, 0), Range::new(0, 20)),
]),
("Excessive motions are performed partially",
vec![
(999, Range::new(0, 0), Range::new(32, 41)),
(999, Range::new(0, 0), Range::new(0, 41)),
]),
("", // Edge case of moving forward in empty string
vec![
@ -1383,11 +1389,11 @@ mod test {
]),
("Multiple motions at once resolve correctly",
vec![
(3, Range::new(18, 18), Range::new(9, 0)),
(3, Range::new(18, 18), Range::new(19, 0)),
]),
("Excessive motions are performed partially",
vec![
(999, Range::new(40, 40), Range::new(10, 0)),
(999, Range::new(40, 40), Range::new(41, 0)),
]),
("", // Edge case of moving backwards in empty string
vec![
@ -1566,11 +1572,11 @@ mod test {
),
(
"Multiple motions at once resolve correctly",
vec![(3, Range::new(19, 19), Range::new(9, 0))],
vec![(3, Range::new(0, 19), Range::new(19, 0))],
),
(
"Excessive motions are performed partially",
vec![(999, Range::new(40, 40), Range::new(10, 0))],
vec![(999, Range::new(40, 40), Range::new(41, 0))],
),
(
"", // Edge case of moving backwards in empty string
@ -1650,11 +1656,11 @@ mod test {
]),
("Multiple motions at once resolve correctly",
vec![
(3, Range::new(0, 0), Range::new(16, 19)),
(3, Range::new(0, 0), Range::new(0, 19)),
]),
("Excessive motions are performed partially",
vec![
(999, Range::new(0, 0), Range::new(31, 41)),
(999, Range::new(0, 0), Range::new(0, 41)),
]),
("", // Edge case of moving forward in empty string
vec![
@ -1732,11 +1738,11 @@ mod test {
]),
("Multiple motions at once resolve correctly",
vec![
(3, Range::new(24, 24), Range::new(16, 8)),
(3, Range::new(24, 24), Range::new(24, 8)),
]),
("Excessive motions are performed partially",
vec![
(999, Range::new(40, 40), Range::new(9, 0)),
(999, Range::new(40, 40), Range::new(41, 0)),
]),
("", // Edge case of moving backwards in empty string
vec![
@ -1900,11 +1906,11 @@ mod test {
]),
("Multiple motions at once resolve correctly",
vec![
(3, Range::new(0, 0), Range::new(16, 19)),
(3, Range::new(0, 0), Range::new(0, 19)),
]),
("Excessive motions are performed partially",
vec![
(999, Range::new(0, 0), Range::new(31, 41)),
(999, Range::new(0, 0), Range::new(0, 41)),
]),
("", // Edge case of moving forward in empty string
vec![
@ -1994,11 +2000,11 @@ mod test {
),
(
"Multiple motions at once resolve correctly",
vec![(3, Range::new(19, 19), Range::new(8, 0))],
vec![(3, Range::new(19, 19), Range::new(19, 0))],
),
(
"Excessive motions are performed partially",
vec![(999, Range::new(40, 40), Range::new(9, 0))],
vec![(999, Range::new(40, 40), Range::new(41, 0))],
),
(
"", // Edge case of moving backwards in empty string

View File

@ -814,7 +814,11 @@ fn goto_line_end_impl(view: &mut View, doc: &mut Document, movement: Movement) {
let pos = graphemes::prev_grapheme_boundary(text, line_end_char_index(&text, line))
.max(line_start);
range.put_cursor(text, pos, movement == Movement::Extend)
if movement != Movement::Extend {
Range::point(range.cursor(text)).put_cursor(text, pos, range.head <= pos)
} else {
range.put_cursor(text, pos, true)
}
});
doc.set_selection(view.id, selection);
}
@ -875,7 +879,14 @@ fn goto_line_start_impl(view: &mut View, doc: &mut Document, movement: Movement)
// adjust to start of the line
let pos = text.line_to_char(line);
range.put_cursor(text, pos, movement == Movement::Extend)
if movement != Movement::Extend {
// ignore head placed at newline, no point to `gh d`?
let head = graphemes::prev_grapheme_boundary(text, line_end_char_index(&text, line))
.min(range.cursor(text));
Range::point(head).put_cursor(text, pos, true)
} else {
range.put_cursor(text, pos, true)
}
});
doc.set_selection(view.id, selection);
}
@ -1005,7 +1016,11 @@ fn goto_first_nonwhitespace_impl(view: &mut View, doc: &mut Document, movement:
if let Some(pos) = text.line(line).first_non_whitespace_char() {
let pos = pos + text.line_to_char(line);
range.put_cursor(text, pos, movement == Movement::Extend)
if movement != Movement::Extend {
Range::point(range.cursor(text)).put_cursor(text, pos, true)
} else {
range.put_cursor(text, pos, true)
}
} else {
range
}

View File

@ -81,6 +81,10 @@ fn request_document_colors(editor: &mut Editor, doc_id: DocumentId) {
})
.collect();
if futures.is_empty() {
return;
}
tokio::spawn(async move {
let mut all_colors = Vec::new();
loop {

View File

@ -1437,7 +1437,11 @@ impl Editor {
log::error!("failed to apply workspace edit: {err:?}")
}
}
if old_path.exists() {
fs::rename(old_path, &new_path)?;
}
if let Some(doc) = self.document_by_path(old_path) {
self.set_doc_path(doc.id(), &new_path);
}

View File

@ -937,7 +937,7 @@ indent = { tab-width = 2, unit = " " }
[[grammar]]
name = "html"
source = { git = "https://github.com/tree-sitter/tree-sitter-html", rev = "29f53d8f4f2335e61bf6418ab8958dac3282077a" }
source = { git = "https://github.com/tree-sitter/tree-sitter-html", rev = "cbb91a0ff3621245e890d1c50cc811bffb77a26b" }
[[language]]
name = "python"

View File

@ -1,3 +1,48 @@
; inherits: html
(tag_name) @tag
(erroneous_end_tag_name) @error
(doctype) @constant
(attribute_name) @attribute
(comment) @comment
((attribute
(attribute_name) @attribute
(quoted_attribute_value (attribute_value) @markup.link.url))
(#any-of? @attribute "href" "src"))
((element
(start_tag
(tag_name) @tag)
(text) @markup.link.label)
(#eq? @tag "a"))
(attribute [(attribute_value) (quoted_attribute_value)] @string)
((element
(start_tag
(tag_name) @tag)
(text) @markup.bold)
(#any-of? @tag "strong" "b"))
((element
(start_tag
(tag_name) @tag)
(text) @markup.italic)
(#any-of? @tag "em" "i"))
((element
(start_tag
(tag_name) @tag)
(text) @markup.strikethrough)
(#any-of? @tag "s" "del"))
[
"<"
">"
"</"
"/>"
"<!"
] @punctuation.bracket
"=" @punctuation.delimiter
["---"] @punctuation.delimiter

View File

@ -12,8 +12,6 @@
(namespace_definition name: (namespace_identifier) @namespace)
(namespace_identifier) @namespace
(qualified_identifier name: (identifier) @type.enum.variant)
(auto) @type
"decltype" @type
@ -21,12 +19,29 @@
(reference_declarator ["&" "&&"] @type.builtin)
(abstract_reference_declarator ["&" "&&"] @type.builtin)
; -------
; Functions
; -------
; Support up to 4 levels of nesting of qualifiers
; i.e. a::b::c::d::func();
(call_expression
function: (qualified_identifier
name: (identifier) @function))
(call_expression
function: (qualified_identifier
name: (qualified_identifier
name: (identifier) @function)))
(call_expression
function: (qualified_identifier
name: (qualified_identifier
name: (qualified_identifier
name: (identifier) @function))))
(call_expression
function: (qualified_identifier
name: (qualified_identifier
name: (qualified_identifier
name: (qualified_identifier
name: (identifier) @function)))))
(template_function
name: (identifier) @function)
@ -34,26 +49,42 @@
(template_method
name: (field_identifier) @function)
; Support up to 3 levels of nesting of qualifiers
; i.e. a::b::c::func();
; Support up to 4 levels of nesting of qualifiers
; i.e. a::b::c::d::func();
(function_declarator
declarator: (qualified_identifier
name: (identifier) @function))
(function_declarator
declarator: (qualified_identifier
name: (qualified_identifier
name: (identifier) @function)))
(function_declarator
declarator: (qualified_identifier
name: (qualified_identifier
name: (qualified_identifier
name: (identifier) @function))))
(function_declarator
declarator: (qualified_identifier
name: (qualified_identifier
name: (qualified_identifier
name: (qualified_identifier
name: (identifier) @function)))))
(function_declarator
declarator: (field_identifier) @function)
; Constructors
(class_specifier
(type_identifier) @type
(field_declaration_list
(function_definition
(function_declarator
(identifier) @constructor)))
(#eq? @type @constructor))
(destructor_name "~" @constructor
(identifier) @constructor)
; Parameters
(parameter_declaration

View File

@ -2,6 +2,7 @@
(erroneous_end_tag_name) @error
(doctype) @constant
(attribute_name) @attribute
(entity) @string.special.symbol
(comment) @comment
((attribute