Skip to content

fix: Rename setting "methodSnippetsInsertText" to "previewMethodSignatureInCompletions` #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ function Foo() {
}
```

`tsEssentialPlugins.methodSnippetsInsertText`:
`tsEssentialPlugins.methodSnippets.previewSignature`:

Optionally resolve insertText of all completion at suggest trigger:

Expand Down
4 changes: 2 additions & 2 deletions src/configurationType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ export type Configuration = {
* Recommended to try!
* @default disable
*/
methodSnippetsInsertText: 'disable' | 'only-local' | 'all'
'methodSnippets.previewSignature': 'disable' | 'only-local' | 'all'
/**
* ```ts
* const example = ({ a }, b?, c = 5, ...d) => { }
Expand Down Expand Up @@ -572,7 +572,7 @@ export type Configuration = {
'experiments.excludeNonJsxCompletions': boolean
/**
* Wether to change function completions to function kind
* @deprecated Use `methodSnippetsInsertText` instead
* @deprecated Use `methodSnippets.previewSignature` instead
* @default false
*/
'experiments.changeKindToFunction': boolean
Expand Down
7 changes: 7 additions & 0 deletions src/migrateSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ export default () => {
mustBePrimitive: false,
},
},
{
rename: {
old: 'methodSnippetsInsertText',
new: 'methodSnippets.previewSignature',
mustBePrimitive: false,
},
},
{
async detect(configuration) {
return !!(await migrateSettingValues(configuration, true))
Expand Down
4 changes: 2 additions & 2 deletions src/onCompletionAccepted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ export default (tsApi: { onCompletionAccepted }) => {
const nextChar = editor.document.getText(new vscode.Range(startPos, startPos.translate(0, 1)))
if (!params || ['(', '.', '`'].includes(nextChar)) return

if (getExtensionSetting('methodSnippetsInsertText') === 'disable') {
// handle insertion only if it wasn't handled by methodSnippetsInsertText already
if (getExtensionSetting('methodSnippets.previewSignature') === 'disable') {
// handle insertion only if it wasn't handled by 'methodSnippets.previewSignature' already
if (isAmbiguous && lastAcceptedAmbiguousMethodSnippetSuggestion !== suggestionName) {
lastAcceptedAmbiguousMethodSnippetSuggestion = suggestionName
return
Expand Down
2 changes: 1 addition & 1 deletion typescript/src/completions/functionCompletions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { sharedCompletionContext } from './sharedContext'
export default (entries: ts.CompletionEntry[]) => {
const { languageService, c, sourceFile, position, prior } = sharedCompletionContext

const methodSnippetInsertTextMode = c('methodSnippetsInsertText')
const methodSnippetInsertTextMode = c('methodSnippets.previewSignature')
const fullText = sourceFile.getFullText()
const nextChar = fullText.slice(position, position + 1)
const prevChar = fullText.slice(position - 1, position)
Expand Down
4 changes: 2 additions & 2 deletions typescript/test/completions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,9 @@ describe('Method snippets', () => {
compareMethodSnippetAgainstMarker(markers, 2, 'ambiguous')
})

test('methodSnippetsInsertText all', () => {
test('methodSnippets.previewSignature all', () => {
overrideSettings({
methodSnippetsInsertText: 'all',
'methodSnippets.previewSignature': 'all',
})
fileContentsSpecialPositions(/* ts */ `
const a = (a, b) => {}
Expand Down