Skip to content

Commit

Permalink
fix: fix get autoSave configurations abnormal
Browse files Browse the repository at this point in the history
  • Loading branch information
libondev committed May 19, 2022
1 parent 06f10a1 commit 2db9f27
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"rules": {
"curly": "off",
"brace-style": "off",
"operator-linebreak": ["error", "after"],
"operator-linebreak": "off",
"@typescript-eslint/brace-style": "off"
}
}
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export interface InsertStatementParams {
editBuilder: TextEditorEdit
}

export type Configurations = 'wrappers' | 'autoSave'

export type InsertPosition = 'before' | 'after'

export interface WrapperContentParams {
Expand Down
17 changes: 7 additions & 10 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { workspace } from 'vscode'
import type {
TextDocument,
WorkspaceConfiguration,
} from 'vscode'
import type { TextDocument } from 'vscode'

import type { InsertPosition, WrapperContentParams } from './types'
import type { Configurations, InsertPosition, WrapperContentParams } from './types'

// Gets the configuration items for the plug-in in the workspace
// 获取工作区中的插件配置项
export function getConfiguration(
configKey: keyof WorkspaceConfiguration,
) {
return workspace.getConfiguration(`debugger-for-console.${configKey}`)
export function getConfiguration(configKey: 'autoSave'): boolean
export function getConfiguration(configKey: 'wrappers'): Record<string, string>
export function getConfiguration(configKey: Configurations) {
return workspace.getConfiguration('debugger-for-console').get(configKey)
}

// Gets the corresponding indentation size based on the line number
Expand All @@ -25,7 +22,7 @@ export function getIndentsByLineNumber(document: TextDocument, lineNumber: numbe
// 读取用户设置文件中的配置(如果没有则会使用插件预设的配置), 获取对应的调试语句
export function getDebuggerStatementByLanguage(document: TextDocument) {
const wrappers = getConfiguration('wrappers')
return (wrappers[document.languageId] || wrappers.default) as string
return wrappers[document.languageId] || wrappers.default
}

// Gets a debug statement inserted into the document
Expand Down

0 comments on commit 2db9f27

Please sign in to comment.