Skip to content

Commit 794ad3a

Browse files
committed
feat: changeEditorLanguageId
fix: debugRememberedConfiguration with compounds
1 parent 21d2763 commit 794ad3a

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import * as vscode from 'vscode'
2+
3+
import { getActiveRegularEditor } from '@zardoy/vscode-utils'
4+
import { registerExtensionCommand } from 'vscode-framework'
5+
6+
export default () => {
7+
// api command simply because workbench.action.editor.changeLanguageMode doesn't support arg
8+
registerExtensionCommand('changeEditorLanguageId' as any, async (_, languageId) => {
9+
if (!languageId) throw new Error('languageId is required as arg')
10+
const editor = getActiveRegularEditor()
11+
if (!editor) return
12+
await vscode.languages.setTextDocumentLanguage(editor.document, languageId)
13+
})
14+
}

src/features/debugRememberedConfiguration.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ export default () => {
1515
const workspace = getCurrentWorkspaceRoot()
1616
const getName = async () => {
1717
const [lastConfigName, pinned] = extensionCtx.workspaceState.get('debugRememberedConfiguration', ['', false] as State)
18-
const configs = await vscode.workspace.fs
19-
.readFile(Utils.joinPath(workspace.uri, '.vscode/launch.json'))
20-
.then(b => jsoncParser.parse(b.toString())?.configurations)
21-
const configNames: string[] = configs.map((c: any) => c.name)
18+
const config = await vscode.workspace.fs.readFile(Utils.joinPath(workspace.uri, '.vscode/launch.json')).then(b => jsoncParser.parse(b.toString()))
19+
const configNames: string[] = [config.configurations, config.compounds].filter(Boolean).flatMap((configs: any) => configs.map(c => c.name))
2220
if (showSelector) {
2321
const pinButton = {
2422
tooltip: 'Pin Choice',

0 commit comments

Comments
 (0)