From e3b67c58e36181c308e200ca49521b3caae309a9 Mon Sep 17 00:00:00 2001 From: Takashi Tamura Date: Sun, 1 Oct 2023 08:57:26 +0900 Subject: [PATCH] Tweak CommandRemover --- src/providers/completionlib/commandremover.ts | 5 ++--- src/providers/completionlib/utils/position.ts | 7 +------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/providers/completionlib/commandremover.ts b/src/providers/completionlib/commandremover.ts index c371e1ae7..ff545a953 100644 --- a/src/providers/completionlib/commandremover.ts +++ b/src/providers/completionlib/commandremover.ts @@ -4,7 +4,7 @@ import { findNodeContactedWithPosition, toLuPos } from '../../utils/utensils' import { IContexAwareProvider } from './interface' import { toVscodePosition } from '../../utils/utensils' import { toVscodeRange } from '../../utils/utensils' -import { isPositionAtTerminator } from './utils/position' +import { isPositionAtClosingBrace } from './utils/position' import { ContextAwareKind } from './completionkind' @@ -15,8 +15,7 @@ export class CommandRemover implements IContexAwareProvider { if (context.triggerKind === vscode.CompletionTriggerKind.TriggerCharacter) { return false } - const wordRange = document.getWordRangeAtPosition(position, /\\[a-zA-Z]+\{/) - if (wordRange || isPositionAtTerminator(document, position)) { + if (isPositionAtClosingBrace(document, position)) { return true } else { return false diff --git a/src/providers/completionlib/utils/position.ts b/src/providers/completionlib/utils/position.ts index 440547811..f028e973d 100644 --- a/src/providers/completionlib/utils/position.ts +++ b/src/providers/completionlib/utils/position.ts @@ -1,11 +1,6 @@ import * as vscode from 'vscode' -export function isPositionAtTerminator(document: vscode.TextDocument, position: vscode.Position): boolean { - const posRange = new vscode.Range(position, position.translate(0, 1)) - const char = document.getText(posRange) - if (char === '\\' || char === '{') { - return true - } +export function isPositionAtClosingBrace(document: vscode.TextDocument, position: vscode.Position): boolean { const prevChar = getPrevChar(document, position) if (prevChar === '}') { return true