@tishlang/tish 2.2.4 → 2.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/tish +0 -0
- package/crates/tish/Cargo.toml +1 -1
- package/crates/tish_lsp/src/main.rs +53 -0
- package/package.json +1 -1
- package/platform/darwin-arm64/tish +0 -0
- package/platform/darwin-x64/tish +0 -0
- package/platform/linux-arm64/tish +0 -0
- package/platform/linux-x64/tish +0 -0
- package/platform/win32-x64/tish.exe +0 -0
package/bin/tish
CHANGED
|
Binary file
|
package/crates/tish/Cargo.toml
CHANGED
|
@@ -119,6 +119,15 @@ fn document_symbol(
|
|
|
119
119
|
selection_range: Range,
|
|
120
120
|
children: Option<Vec<DocumentSymbol>>,
|
|
121
121
|
) -> DocumentSymbol {
|
|
122
|
+
// LSP spec: selectionRange must be contained in range, or VS Code rejects the whole document
|
|
123
|
+
// outline ("selectionRange must be contained in fullRange"). Some declaration spans are
|
|
124
|
+
// unset/degenerate (e.g. a top-level VarDecl's span defaults to an empty range) and so do not
|
|
125
|
+
// enclose the name span; fall back to the name range to keep the invariant.
|
|
126
|
+
let contains = (range.start.line, range.start.character)
|
|
127
|
+
<= (selection_range.start.line, selection_range.start.character)
|
|
128
|
+
&& (selection_range.end.line, selection_range.end.character)
|
|
129
|
+
<= (range.end.line, range.end.character);
|
|
130
|
+
let range = if contains { range } else { selection_range };
|
|
122
131
|
DocumentSymbol {
|
|
123
132
|
name,
|
|
124
133
|
detail,
|
|
@@ -1671,6 +1680,50 @@ mod hover_tests {
|
|
|
1671
1680
|
assert_eq!(full_doc_end(""), (0, 0));
|
|
1672
1681
|
assert_eq!(full_doc_end("café"), (0, 4)); // UTF-16 units (é = 1), not bytes (5)
|
|
1673
1682
|
}
|
|
1683
|
+
|
|
1684
|
+
#[test]
|
|
1685
|
+
fn doc_symbols_satisfy_lsp_selection_containment() {
|
|
1686
|
+
// LSP requires every DocumentSymbol's selectionRange ⊆ range, or VS Code rejects the
|
|
1687
|
+
// whole outline ("selectionRange must be contained in fullRange"). Exercise the
|
|
1688
|
+
// declaration forms the outline emits.
|
|
1689
|
+
use tower_lsp::lsp_types::DocumentSymbol;
|
|
1690
|
+
fn check(syms: &[DocumentSymbol], src: &str) {
|
|
1691
|
+
for s in syms {
|
|
1692
|
+
let (r, sel) = (&s.range, &s.selection_range);
|
|
1693
|
+
let contained = (r.start.line, r.start.character)
|
|
1694
|
+
<= (sel.start.line, sel.start.character)
|
|
1695
|
+
&& (sel.end.line, sel.end.character) <= (r.end.line, r.end.character);
|
|
1696
|
+
assert!(
|
|
1697
|
+
contained,
|
|
1698
|
+
"selectionRange {sel:?} not contained in range {r:?} for `{}` in:\n{src}",
|
|
1699
|
+
s.name
|
|
1700
|
+
);
|
|
1701
|
+
if let Some(children) = &s.children {
|
|
1702
|
+
check(children, src);
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
let sources = [
|
|
1707
|
+
"fn f(x) { return x }\n",
|
|
1708
|
+
"let a = 1\n",
|
|
1709
|
+
"let a = 1, b = 2\n",
|
|
1710
|
+
"export fn g() { return 1 }\n",
|
|
1711
|
+
"export let x = 1\n",
|
|
1712
|
+
"type T = number\n",
|
|
1713
|
+
"declare fn h(): void\n",
|
|
1714
|
+
"declare let y: number\n",
|
|
1715
|
+
"fn outer() {\n fn inner() { return 1 }\n return inner\n}\n",
|
|
1716
|
+
"export type Opts = { a: number }\n",
|
|
1717
|
+
];
|
|
1718
|
+
for src in sources {
|
|
1719
|
+
let p = parse(src);
|
|
1720
|
+
let mut syms = Vec::new();
|
|
1721
|
+
for s in &p.statements {
|
|
1722
|
+
doc_symbol_stmt(s, src, &mut syms);
|
|
1723
|
+
}
|
|
1724
|
+
check(&syms, src);
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1674
1727
|
}
|
|
1675
1728
|
|
|
1676
1729
|
#[cfg(test)]
|
package/package.json
CHANGED
|
Binary file
|
package/platform/darwin-x64/tish
CHANGED
|
Binary file
|
|
Binary file
|
package/platform/linux-x64/tish
CHANGED
|
Binary file
|
|
Binary file
|