Skip to content

Commit

Permalink
Fix: must be return Snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
uga-rosa committed Dec 5, 2023
1 parent 4efabc8 commit 9010ff1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
2 changes: 1 addition & 1 deletion denops/denippet/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class Session {
prefix?: string,
): Promise<boolean> {
const snippet = await Snippet.create(this.denops, body, this.snippet, prefix);
if (snippet != null) {
if (snippet.jumpableNodes.length > 0 && snippet.jumpableNodes[0].tabstop > 0) {
this.snippet = snippet;
return true;
} else {
Expand Down
16 changes: 3 additions & 13 deletions denops/denippet/snippet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class Snippet {
body: string,
outer?: Snippet,
prefix?: string,
): Promise<Snippet | undefined> {
): Promise<Snippet> {
const snippetNode = await parse(denops, body);

// Resolve reference relationships using breadth first search.
Expand Down Expand Up @@ -77,20 +77,10 @@ export class Snippet {
// Calculate range each node
await snippetNode.updateRange(cursor);

const snippet = new Snippet(denops, snippetNode, jumpableNodes, outer);

// Jump to the first node
if (snippet.currentNode() == null) {
return;
} else {
await snippet.currentNode().jump();
}

// This also implicitly indicates jumpableNodes.length === 1.
if (snippet.currentNode().tabstop == 0) {
return;
}
await jumpableNodes[0]?.jump();

const snippet = new Snippet(denops, snippetNode, jumpableNodes, outer);
await snippet.doNodeEnter();
return snippet;
}
Expand Down

0 comments on commit 9010ff1

Please sign in to comment.