Merge pull request #1398 from tree-sitter/feat/cli/improve-query-output

feat(cli/query): Improve and unify query sub command output
This commit is contained in:
Max Brunsfeld 2021-09-21 13:46:26 -07:00 committed by GitHub
commit 51aa169387
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -48,10 +48,12 @@ pub fn query_files_at_paths(
let capture_name = &query.capture_names()[capture.index as usize];
writeln!(
&mut stdout,
" pattern: {}, capture: {}, row: {}, text: {:?}",
" pattern: {:>2}, capture: {} - {}, start: {}, end: {}, text: `{}`",
mat.pattern_index,
capture.index,
capture_name,
capture.node.start_position().row,
capture.node.start_position(),
capture.node.end_position(),
capture.node.utf8_text(&source_code).unwrap_or("")
)?;
results.push(query_testing::CaptureInfo {
@ -70,9 +72,11 @@ pub fn query_files_at_paths(
if end.row == start.row {
writeln!(
&mut stdout,
" capture: {}, start: {}, text: {:?}",
" capture: {} - {}, start: {}, end: {}, text: `{}`",
capture.index,
capture_name,
start,
end,
capture.node.utf8_text(&source_code).unwrap_or("")
)?;
} else {