More fixes to the semantic index's chunking (#11376)
This fixes a tricky intermittent issue I was seeing, where failed to chunk certain files correctly because of the way we reuse Tree-sitter `Parser` instances across parses. I've also accounted for leading comments in chunk boundaries, so that items are grouped with their leading comments whenever possible when chunking. Finally, we've changed the `debug project index` action so that it opens a simple debug view in a pane, instead of printing paths to the console. This lets you click into a path and see how it was chunked. Release Notes: - N/A --------- Co-authored-by: Marshall <marshall@zed.dev>
This commit is contained in:
parent
335c307b93
commit
6964302d89
11 changed files with 532 additions and 171 deletions
|
@ -1818,7 +1818,7 @@ fn test_language_scope_at_with_javascript(cx: &mut AppContext) {
|
|||
let snapshot = buffer.snapshot();
|
||||
|
||||
let config = snapshot.language_scope_at(0).unwrap();
|
||||
assert_eq!(config.line_comment_prefixes().unwrap(), &[Arc::from("// ")]);
|
||||
assert_eq!(config.line_comment_prefixes(), &[Arc::from("// ")]);
|
||||
// Both bracket pairs are enabled
|
||||
assert_eq!(
|
||||
config.brackets().map(|e| e.1).collect::<Vec<_>>(),
|
||||
|
@ -1828,10 +1828,7 @@ fn test_language_scope_at_with_javascript(cx: &mut AppContext) {
|
|||
let string_config = snapshot
|
||||
.language_scope_at(text.find("b\"").unwrap())
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
string_config.line_comment_prefixes().unwrap(),
|
||||
&[Arc::from("// ")]
|
||||
);
|
||||
assert_eq!(string_config.line_comment_prefixes(), &[Arc::from("// ")]);
|
||||
// Second bracket pair is disabled
|
||||
assert_eq!(
|
||||
string_config.brackets().map(|e| e.1).collect::<Vec<_>>(),
|
||||
|
@ -1842,7 +1839,7 @@ fn test_language_scope_at_with_javascript(cx: &mut AppContext) {
|
|||
let element_config = snapshot
|
||||
.language_scope_at(text.find("<F>").unwrap())
|
||||
.unwrap();
|
||||
assert_eq!(element_config.line_comment_prefixes(), None);
|
||||
assert_eq!(element_config.line_comment_prefixes(), &[]);
|
||||
assert_eq!(
|
||||
element_config.block_comment_delimiters(),
|
||||
Some((&"{/*".into(), &"*/}".into()))
|
||||
|
@ -1856,10 +1853,7 @@ fn test_language_scope_at_with_javascript(cx: &mut AppContext) {
|
|||
let tag_config = snapshot
|
||||
.language_scope_at(text.find(" d=").unwrap() + 1)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
tag_config.line_comment_prefixes().unwrap(),
|
||||
&[Arc::from("// ")]
|
||||
);
|
||||
assert_eq!(tag_config.line_comment_prefixes(), &[Arc::from("// ")]);
|
||||
assert_eq!(
|
||||
tag_config.brackets().map(|e| e.1).collect::<Vec<_>>(),
|
||||
&[true, true]
|
||||
|
@ -1870,9 +1864,7 @@ fn test_language_scope_at_with_javascript(cx: &mut AppContext) {
|
|||
.language_scope_at(text.find('{').unwrap() + 1)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
expression_in_element_config
|
||||
.line_comment_prefixes()
|
||||
.unwrap(),
|
||||
expression_in_element_config.line_comment_prefixes(),
|
||||
&[Arc::from("// ")]
|
||||
);
|
||||
assert_eq!(
|
||||
|
@ -1988,17 +1980,14 @@ fn test_language_scope_at_with_combined_injections(cx: &mut AppContext) {
|
|||
|
||||
let snapshot = buffer.snapshot();
|
||||
let html_config = snapshot.language_scope_at(Point::new(2, 4)).unwrap();
|
||||
assert_eq!(html_config.line_comment_prefixes(), Some(&vec![]));
|
||||
assert_eq!(html_config.line_comment_prefixes(), &[]);
|
||||
assert_eq!(
|
||||
html_config.block_comment_delimiters(),
|
||||
Some((&"<!--".into(), &"-->".into()))
|
||||
);
|
||||
|
||||
let ruby_config = snapshot.language_scope_at(Point::new(3, 12)).unwrap();
|
||||
assert_eq!(
|
||||
ruby_config.line_comment_prefixes().unwrap(),
|
||||
&[Arc::from("# ")]
|
||||
);
|
||||
assert_eq!(ruby_config.line_comment_prefixes(), &[Arc::from("# ")]);
|
||||
assert_eq!(ruby_config.block_comment_delimiters(), None);
|
||||
|
||||
buffer
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue