Skip to content

Commit

Permalink
Cleanup latex
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasArvidsson committed Nov 19, 2024
1 parent 78ebe56 commit 99aa3d0
Showing 1 changed file with 1 addition and 33 deletions.
34 changes: 1 addition & 33 deletions packages/cursorless-engine/src/languages/latex.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { SimpleScopeTypeType, TextEditor } from "@cursorless/common";
import { Range, Selection } from "@cursorless/common";
import { Selection } from "@cursorless/common";
import type { SyntaxNode } from "web-tree-sitter";
import type {
NodeMatcherAlternative,
Expand Down Expand Up @@ -120,36 +120,6 @@ function extendToNamedSiblingIfExists(
};
}

function extractItemContent(
editor: TextEditor,
node: SyntaxNode,
): SelectionWithContext {
let contentStartIndex = node.startIndex;

const label = node.childForFieldName("label");
if (label == null) {
const command = node.childForFieldName("command");
if (command != null) {
contentStartIndex = command.endIndex + 1;
}
} else {
contentStartIndex = label.endIndex + 1;
}

return {
selection: new Selection(
editor.document.positionAt(contentStartIndex),
editor.document.positionAt(node.endIndex),
),
context: {
leadingDelimiterRange: new Range(
editor.document.positionAt(node.startIndex),
editor.document.positionAt(contentStartIndex - 1),
),
},
};
}

const nodeMatchers: Partial<
Record<SimpleScopeTypeType, NodeMatcherAlternative>
> = {
Expand All @@ -174,8 +144,6 @@ const nodeMatchers: Partial<
matcher(patternFinder(...sectioningText), unwrapGroupParens),
patternMatcher("begin[name][text]", "end[name][text]"),
),

collectionItem: matcher(patternFinder("enum_item"), extractItemContent),
};

export default createPatternMatchers(nodeMatchers);

0 comments on commit 99aa3d0

Please sign in to comment.