File tree Expand file tree Collapse file tree
typescript/src/completions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -498,11 +498,11 @@ export type Configuration = {
498498 */
499499 // 'objectLiteralCompletions.deepVariants': 'disable' | 'displayBelow' | 'replaceNotDeep'
500500 /**
501- * Also affects builtin typescript.suggest.objectLiteralMethodSnippets, even when additional completions disabled
502- * @default below
501+ * How to position original suggestion relative to snippet suggestion.
502+ * Also affects builtin typescript.suggest.objectLiteralMethodSnippets, even when additional plugin completions disabled
503+ * @default before
503504 */
504- // TODO its a bug, change to after & before with fixed behavior
505- 'objectLiteralCompletions.keepOriginal' : 'below' | 'above' | 'remove'
505+ 'objectLiteralCompletions.keepOriginal' : 'before' | 'after' | 'remove'
506506 /**
507507 * Wether to exclude non-JSX components completions in JSX component locations
508508 * Requires TypeScript 5.0+
Original file line number Diff line number Diff line change 1+ import * as vscode from 'vscode'
12import { migrateExtensionSettings } from '@zardoy/vscode-utils/build/migrateSettings'
3+ import { Settings } from 'vscode-framework'
24
35export default ( ) => {
46 void migrateExtensionSettings (
@@ -31,7 +33,34 @@ export default () => {
3133 mustBePrimitive : false ,
3234 } ,
3335 } ,
36+ {
37+ async detect ( configuration ) {
38+ return ! ! ( await migrateSettingValues ( configuration , true ) )
39+ } ,
40+ async handle ( configuration ) {
41+ return ( await migrateSettingValues ( configuration , false ) ) !
42+ } ,
43+ } ,
3444 ] ,
3545 process . env . IDS_PREFIX ! ,
3646 )
3747}
48+
49+ async function migrateSettingValues ( configuration : vscode . WorkspaceConfiguration , detectOnly : boolean ) {
50+ const keepOriginalSettingKey : keyof Settings = 'objectLiteralCompletions.keepOriginal'
51+ const keepOriginal = configuration . get < string > ( keepOriginalSettingKey ) !
52+ const keepOriginalNewValuesMap = {
53+ below : 'before' ,
54+ above : 'after' ,
55+ }
56+ const newKeepOriginalValue = keepOriginalNewValuesMap [ keepOriginal ]
57+ if ( newKeepOriginalValue ) {
58+ if ( ! detectOnly ) {
59+ await configuration . update ( keepOriginalSettingKey , newKeepOriginalValue , vscode . ConfigurationTarget . Global )
60+ }
61+
62+ return keepOriginalSettingKey
63+ }
64+
65+ return undefined
66+ }
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ export default (
3232 const methodEntry = entries [ methodEntryIndex ]
3333 if ( methodEntry ) {
3434 entries . splice ( methodEntryIndex , 1 )
35- entries . splice ( entries . indexOf ( entry ) + ( keepOriginal === 'below ' ? 1 : 0 ) , keepOriginal === 'remove' ? 1 : 0 , {
35+ entries . splice ( entries . indexOf ( entry ) + ( keepOriginal === 'before ' ? 1 : 0 ) , keepOriginal === 'remove' ? 1 : 0 , {
3636 ...methodEntry ,
3737 // let correctSorting.enable sort it
3838 sortText : entry . sortText ,
@@ -59,7 +59,7 @@ export default (
5959 const [ insertSnippetText , insertSnippetPreview ] = typeof insertSnippetVariant === 'function' ? insertSnippetVariant ( ) : insertSnippetVariant
6060 const insertText = entry . name + insertSnippetText
6161 const index = entries . indexOf ( entry )
62- entries . splice ( index + ( keepOriginal === 'below ' ? 1 : 0 ) , keepOriginal === 'remove' ? 1 : 0 , {
62+ entries . splice ( index + ( keepOriginal === 'before ' ? 1 : 0 ) , keepOriginal === 'remove' ? 1 : 0 , {
6363 ...entry ,
6464 // todo setting incompatible!!!
6565 sortText : entry . sortText ,
You can’t perform that action at this time.
0 commit comments