Skip to content

Commit

Permalink
Fix to adapt formatter at all tabstops before drop
Browse files Browse the repository at this point in the history
  • Loading branch information
uga-rosa committed Dec 3, 2023
1 parent 3f3ef66 commit 069b5f1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions denops/denippet/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function main(denops: Denops): void {
clearTimeout(timeoutId);
timeoutId = setTimeout(async () => {
const id = lambda.register(denops, async () => {
await session.update();
await session.update(session.snippet?.currentNode().tabstop);
return true;
});
await denops.call(
Expand All @@ -65,9 +65,9 @@ export function main(denops: Denops): void {
}, syncDelay);
}

async function forceUpdate(): Promise<void> {
async function forceUpdate(tabstop?: number): Promise<void> {
clearTimeout(timeoutId);
await session.update();
await session.update(tabstop);
}

denops.dispatcher = {
Expand Down Expand Up @@ -123,7 +123,7 @@ export function main(denops: Denops): void {
if (syncDelay >= 0) {
const updateId = lambda.register(denops, async () => {
if (syncDelay === 0) {
await session.update();
await session.update(session.snippet?.currentNode().tabstop);
} else if (syncDelay > 0) {
debounceUpdate(syncDelay);
}
Expand All @@ -149,7 +149,7 @@ export function main(denops: Denops): void {
return;
}
if ((await fn.mode(denops))[0] === "i") {
await forceUpdate();
await forceUpdate(session.snippet.currentNode().tabstop);
}
session.guard();
await session.jump(dir);
Expand Down
4 changes: 2 additions & 2 deletions denops/denippet/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ export class Session {
await clearExtmark(this.denops);
}

async update(): Promise<void> {
async update(tabstop?: number): Promise<void> {
if (this.isGuarded) {
return;
}
try {
await this.snippet?.update();
await this.snippet?.update(tabstop);
} catch (e) {
echoerr(this.denops, e);
await this.drop();
Expand Down
4 changes: 2 additions & 2 deletions denops/denippet/snippet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ export class Snippet {
return this.jumpableNodes[this.nodeIndex];
}

async update(): Promise<void> {
async update(tabstop?: number): Promise<void> {
await this.currentNode().updateInput();
const eventignore = await op.eventignore.get(this.denops);
await op.eventignore.set(this.denops, "all");
await this.snippet.updateRange(undefined, this.currentNode().tabstop);
await this.snippet.updateRange(undefined, tabstop);
await op.eventignore.set(this.denops, eventignore);
// Extmark could disappear with updateRange().
await this.currentNode().setExtmark();
Expand Down

0 comments on commit 069b5f1

Please sign in to comment.