task: Allow obtaining custom task variables from tree-sitter queries (#11624)
From now on, only top-level captures are treated as runnable tags and the rest is appended to task context as custom environmental variables (unless the name is prefixed with _, in which case the capture is ignored). This is most likely gonna help with Pest-like test runners. Release Notes: - N/A --------- Co-authored-by: Remco <djsmits12@gmail.com>
This commit is contained in:
parent
95e246ac1c
commit
bff1d8b142
7 changed files with 126 additions and 67 deletions
|
@ -13,7 +13,7 @@ use language::{
|
|||
language_settings::{language_settings, LanguageSettings},
|
||||
AutoindentMode, Buffer, BufferChunks, BufferSnapshot, Capability, CharKind, Chunk, CursorShape,
|
||||
DiagnosticEntry, File, IndentSize, Language, LanguageScope, OffsetRangeExt, OffsetUtf16,
|
||||
Outline, OutlineItem, Point, PointUtf16, Runnable, Selection, TextDimension, ToOffset as _,
|
||||
Outline, OutlineItem, Point, PointUtf16, Selection, TextDimension, ToOffset as _,
|
||||
ToOffsetUtf16 as _, ToPoint as _, ToPointUtf16 as _, TransactionId, Unclipped,
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
|
@ -3168,7 +3168,7 @@ impl MultiBufferSnapshot {
|
|||
pub fn runnable_ranges(
|
||||
&self,
|
||||
range: Range<Anchor>,
|
||||
) -> impl Iterator<Item = (BufferId, Range<usize>, Runnable)> + '_ {
|
||||
) -> impl Iterator<Item = language::RunnableRange> + '_ {
|
||||
let range = range.start.to_offset(self)..range.end.to_offset(self);
|
||||
self.excerpts_for_range(range.clone())
|
||||
.flat_map(move |(excerpt, excerpt_offset)| {
|
||||
|
@ -3177,16 +3177,16 @@ impl MultiBufferSnapshot {
|
|||
excerpt
|
||||
.buffer
|
||||
.runnable_ranges(excerpt.range.context.clone())
|
||||
.map(move |(mut match_range, runnable)| {
|
||||
.map(move |mut runnable| {
|
||||
// Re-base onto the excerpts coordinates in the multibuffer
|
||||
match_range.start =
|
||||
excerpt_offset + (match_range.start - excerpt_buffer_start);
|
||||
match_range.end = excerpt_offset + (match_range.end - excerpt_buffer_start);
|
||||
|
||||
(excerpt.buffer_id, match_range, runnable)
|
||||
runnable.run_range.start =
|
||||
excerpt_offset + (runnable.run_range.start - excerpt_buffer_start);
|
||||
runnable.run_range.end =
|
||||
excerpt_offset + (runnable.run_range.end - excerpt_buffer_start);
|
||||
runnable
|
||||
})
|
||||
.skip_while(move |(_, match_range, _)| match_range.end < range.start)
|
||||
.take_while(move |(_, match_range, _)| match_range.start < range.end)
|
||||
.skip_while(move |runnable| runnable.run_range.end < range.start)
|
||||
.take_while(move |runnable| runnable.run_range.start < range.end)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue