Conversation
|
This is marked a draft, so just a quick glance. I'm generally in favor of this feature. It needs to be documented and the lsp needs to support it in its path completion. Also the tree-sitter grammar needs to be adjusted. |
|
I had three more thoughts about this feature:
|
tronical
left a comment
There was a problem hiding this comment.
Looks like a good direction - would love to have this in the next release.
Request to address the comments, #10920 (comment) ,
#10920 (comment) as well as the need for test coverage, including the errors.
| let resolved_path = ctx | ||
| .type_loader | ||
| .and_then(|loader| loader.resolve_import_path(Some(&(*node).clone().into()), &s)) | ||
| .map(|i| i.0.to_string_lossy().into()) | ||
| .unwrap_or_else(|| { | ||
| crate::pathutils::join( | ||
| &crate::pathutils::dirname(node.source_file.path()), | ||
| path, | ||
| ) | ||
| .map(|p| p.to_string_lossy().into()) | ||
| .unwrap_or(s.clone()) | ||
| }); |
There was a problem hiding this comment.
Since this code is duplicated from from_at_image_url_node, I think it presents a good candidate for moving that into a helper function.
| .unwrap_or(s.clone()) | ||
| }); | ||
|
|
||
| match std::fs::read_to_string(&resolved_path) { |
There was a problem hiding this comment.
I think the approach of embedding the text should be the same that we also use for images. So for Rust we use include_bytes!() (could be include_str!()), and for C++ we read the file at slint-compiler run-time and then embed it as an array or perhaps a u8 literal.
I have the feeling that this will require a dedicated Expression that can be handled in the generators as well as from_at_markdown.
This is almost entirely bashed out by AI. It mostly looks good, though
parse_include_stringandfrom_at_include_string_nodecould probably be more concise. Will clean up before merging.