File tree Expand file tree Collapse file tree 3 files changed +35
-6
lines changed
typescript/src/completions Expand file tree Collapse file tree 3 files changed +35
-6
lines changed Original file line number Diff line number Diff line change @@ -498,11 +498,11 @@ export type Configuration = {
498
498
*/
499
499
// 'objectLiteralCompletions.deepVariants': 'disable' | 'displayBelow' | 'replaceNotDeep'
500
500
/**
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
503
504
*/
504
- // TODO its a bug, change to after & before with fixed behavior
505
- 'objectLiteralCompletions.keepOriginal' : 'below' | 'above' | 'remove'
505
+ 'objectLiteralCompletions.keepOriginal' : 'before' | 'after' | 'remove'
506
506
/**
507
507
* Wether to exclude non-JSX components completions in JSX component locations
508
508
* Requires TypeScript 5.0+
Original file line number Diff line number Diff line change
1
+ import * as vscode from 'vscode'
1
2
import { migrateExtensionSettings } from '@zardoy/vscode-utils/build/migrateSettings'
3
+ import { Settings } from 'vscode-framework'
2
4
3
5
export default ( ) => {
4
6
void migrateExtensionSettings (
@@ -31,7 +33,34 @@ export default () => {
31
33
mustBePrimitive : false ,
32
34
} ,
33
35
} ,
36
+ {
37
+ async detect ( configuration ) {
38
+ return ! ! ( await migrateSettingValues ( configuration , true ) )
39
+ } ,
40
+ async handle ( configuration ) {
41
+ return ( await migrateSettingValues ( configuration , false ) ) !
42
+ } ,
43
+ } ,
34
44
] ,
35
45
process . env . IDS_PREFIX ! ,
36
46
)
37
47
}
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 (
32
32
const methodEntry = entries [ methodEntryIndex ]
33
33
if ( methodEntry ) {
34
34
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 , {
36
36
...methodEntry ,
37
37
// let correctSorting.enable sort it
38
38
sortText : entry . sortText ,
@@ -59,7 +59,7 @@ export default (
59
59
const [ insertSnippetText , insertSnippetPreview ] = typeof insertSnippetVariant === 'function' ? insertSnippetVariant ( ) : insertSnippetVariant
60
60
const insertText = entry . name + insertSnippetText
61
61
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 , {
63
63
...entry ,
64
64
// todo setting incompatible!!!
65
65
sortText : entry . sortText ,
You can’t perform that action at this time.
0 commit comments