Skip to content

Commit

Permalink
Merge branch 'tweak_remove_command'
Browse files Browse the repository at this point in the history
  • Loading branch information
tamuratak committed Oct 1, 2023
2 parents 630811b + e3b67c5 commit 6ea6d56
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
5 changes: 2 additions & 3 deletions src/providers/completionlib/commandremover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'


Expand All @@ -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
Expand Down
7 changes: 1 addition & 6 deletions src/providers/completionlib/utils/position.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 6ea6d56

Please sign in to comment.