11/* eslint-disable @typescript-eslint/no-require-imports */
22import * as vscode from 'vscode'
33import { defaultJsSupersetLangs } from '@zardoy/vscode-utils/build/langs'
4- import { Settings , extensionCtx , getExtensionSetting , getExtensionSettingId , registerExtensionCommand } from 'vscode-framework'
4+ import { extensionCtx , getExtensionSetting , getExtensionSettingId } from 'vscode-framework'
55import { pickObj } from '@zardoy/utils'
66import { watchExtensionSettings } from '@zardoy/vscode-utils/build/settings'
7- import { ConditionalPick } from 'type-fest'
87import webImports from './webImports'
98import { sendCommand } from './sendCommand'
109import { registerEmmet } from './emmet'
@@ -27,13 +26,21 @@ export const activateTsPlugin = (tsApi: { configurePlugin; onCompletionAccepted
2726 isActivated = true
2827 let webWaitingForConfigSync = false
2928
29+ const getResolvedConfig = ( ) => {
30+ const configuration = vscode . workspace . getConfiguration ( )
31+ const config : any = {
32+ ...configuration . get ( process . env . IDS_PREFIX ! ) ,
33+ editorSuggestInsertModeReplace : configuration . get ( 'editor.suggest.insertMode' ) === 'replace' ,
34+ }
35+ mergeSettingsFromScopes ( config , 'typescript' , extensionCtx . extension . packageJSON )
36+ return config
37+ }
38+
3039 const syncConfig = ( ) => {
3140 if ( ! tsApi ) return
3241 console . log ( 'sending configure request for typescript-essential-plugins' )
33- const config : any = { ...vscode . workspace . getConfiguration ( ) . get ( process . env . IDS_PREFIX ! ) }
3442 // todo implement language-specific settings
35- mergeSettingsFromScopes ( config , 'typescript' , extensionCtx . extension . packageJSON )
36-
43+ const config = getResolvedConfig ( )
3744 tsApi . configurePlugin ( 'typescript-essential-plugins' , config )
3845
3946 if ( process . env . PLATFORM === 'node' ) {
@@ -50,7 +57,7 @@ export const activateTsPlugin = (tsApi: { configurePlugin; onCompletionAccepted
5057 }
5158
5259 vscode . workspace . onDidChangeConfiguration ( async ( { affectsConfiguration } ) => {
53- if ( affectsConfiguration ( process . env . IDS_PREFIX ! ) ) {
60+ if ( affectsConfiguration ( process . env . IDS_PREFIX ! ) || affectsConfiguration ( 'editor.suggest.insertMode' ) ) {
5461 syncConfig ( )
5562 if (
5663 process . env . PLATFORM === 'node' &&
@@ -72,7 +79,7 @@ export const activateTsPlugin = (tsApi: { configurePlugin; onCompletionAccepted
7279 if ( ! activeTextEditor || ! vscode . languages . match ( defaultJsSupersetLangs , activeTextEditor . document ) ) return
7380 if ( ! webWaitingForConfigSync ) return
7481 // webWaitingForConfigSync = false
75- const config = vscode . workspace . getConfiguration ( ) . get ( process . env . IDS_PREFIX ! )
82+ const config = getResolvedConfig ( )
7683 void sendCommand ( `updateConfig${ JSON . stringify ( config ) } ` as any )
7784 }
7885
0 commit comments