|
1 |
| -import { Range, Selection, TextEditor } from "@cursorless/common"; |
| 1 | +import { Range, SimpleScopeTypeType, TextEditor } from "@cursorless/common"; |
2 | 2 | import type { SyntaxNode } from "web-tree-sitter";
|
3 |
| -import { getMatchesInRange } from "../util/getMatchesInRange"; |
4 |
| -import { SimpleScopeTypeType } from "@cursorless/common"; |
5 | 3 | import {
|
6 | 4 | NodeFinder,
|
7 | 5 | NodeMatcherAlternative,
|
8 | 6 | SelectionWithContext,
|
9 | 7 | } from "../typings/Types";
|
| 8 | +import { getMatchesInRange } from "../util/getMatchesInRange"; |
10 | 9 | import { leadingSiblingNodeFinder, patternFinder } from "../util/nodeFinders";
|
11 | 10 | import { createPatternMatchers, matcher } from "../util/nodeMatchers";
|
12 | 11 | import {
|
13 | 12 | extendUntilNextMatchingSiblingOrLast,
|
14 |
| - getNodeRange, |
15 | 13 | selectWithLeadingDelimiter,
|
16 | 14 | } from "../util/nodeSelectors";
|
17 | 15 | import { shrinkRangeToFitContent } from "../util/selectionUtils";
|
18 | 16 |
|
19 |
| -/** |
20 |
| - * Given a node representing the text of a section heading (without leading |
21 |
| - * marker), will return the content range as the text without the leading |
22 |
| - * whitespace, and the outside range includes the leading marker, so that |
23 |
| - * "chuck name" deletes the heading |
24 |
| - * @param editor The editor containing the node |
25 |
| - * @param node The node to extract from; will be the content of the heading without the leading marker |
26 |
| - * @returns The selection with context |
27 |
| - */ |
28 |
| -function nameExtractor( |
29 |
| - editor: TextEditor, |
30 |
| - node: SyntaxNode, |
31 |
| -): SelectionWithContext { |
32 |
| - const range = getNodeRange(node); |
33 |
| - const contentRange = range.isEmpty |
34 |
| - ? range |
35 |
| - : range.with(range.start.translate(0, 1)); |
36 |
| - const removalRange = getNodeRange(node.parent!); |
37 |
| - |
38 |
| - return { |
39 |
| - selection: new Selection(contentRange.start, contentRange.end), |
40 |
| - context: { |
41 |
| - removalRange, |
42 |
| - }, |
43 |
| - }; |
44 |
| -} |
45 |
| - |
46 | 17 | const HEADING_MARKER_TYPES = [
|
47 | 18 | "atx_h1_marker",
|
48 | 19 | "atx_h2_marker",
|
@@ -139,12 +110,6 @@ function itemExtractor(
|
139 | 110 | const nodeMatchers: Partial<
|
140 | 111 | Record<SimpleScopeTypeType, NodeMatcherAlternative>
|
141 | 112 | > = {
|
142 |
| - list: ["list"], |
143 |
| - comment: "html_block", |
144 |
| - name: matcher( |
145 |
| - leadingSiblingNodeFinder(patternFinder("atx_heading[heading_content]")), |
146 |
| - nameExtractor, |
147 |
| - ), |
148 | 113 | collectionItem: matcher(patternFinder("list_item.paragraph!"), itemExtractor),
|
149 | 114 | section: sectionMatcher("atx_heading"),
|
150 | 115 | sectionLevelOne: sectionMatcher("atx_heading.atx_h1_marker"),
|
|
0 commit comments