bool ShouldPassThroughEnterKey(EnterKeyRule enterKeyRule) { if (enterKeyRule == EnterKeyRule.Default) enterKeyRule = TryGetRoslynCompletionService()?.GetRules().DefaultEnterKeyRule ?? enterKeyRule; switch (enterKeyRule) { case EnterKeyRule.Never: return false; case EnterKeyRule.Always: return true; case EnterKeyRule.AfterFullyTypedWord: if (!HasSession) return false; var completion = completionSession.SelectedCompletionSet?.SelectionStatus.Completion; if (completion == null) return false; var span = completionSession.SelectedCompletionSet.ApplicableTo; var text = span.GetText(span.TextBuffer.CurrentSnapshot); return text.Equals(completion.TryGetFilterText(), StringComparison.CurrentCultureIgnoreCase); case EnterKeyRule.Default: return false; default: Debug.Fail($"New {nameof(EnterKeyRule)} value: {enterKeyRule}"); goto case EnterKeyRule.Default; } }
public async Task SendEnterThroughToEditorTest(EnterKeyRule enterKeyRule) => await VerifySendEnterThroughToEnterAsync( "#r \"System$$", "System", enterKeyRule, expected : false );
public async Task <bool> CheckAndCommit(char insertedChar) { CompletionItem item = CompletionListControl.Items[CompletionListControl.SelectedIndex].item; List <char> commitCharacters = new List <char>(CompletionList.Rules.DefaultCommitCharacters); foreach (CharacterSetModificationRule rule in item.Rules.CommitCharacterRules) { if (rule.Kind == CharacterSetModificationKind.Add) { commitCharacters.AddRange(rule.Characters); } else if (rule.Kind == CharacterSetModificationKind.Remove) { foreach (char c in rule.Characters) { commitCharacters.Remove(c); } } else if (rule.Kind == CharacterSetModificationKind.Replace) { commitCharacters = new List <char>(rule.Characters); } } if (commitCharacters.Contains(insertedChar) || insertedChar == '\n' || insertedChar == '\r') { await Commit(item); } bool tbr = false; if (insertedChar == '\n' || insertedChar == '\r') { EnterKeyRule enterRule = item.Rules.EnterKeyRule; if (enterRule == EnterKeyRule.Default) { enterRule = CompletionList.Rules.DefaultEnterKeyRule; } switch (enterRule) { case EnterKeyRule.Always: tbr = false; break; case EnterKeyRule.Never: tbr = true; break; case EnterKeyRule.AfterFullyTypedWord: tbr = FilterText.Equals(item.DisplayText, StringComparison.OrdinalIgnoreCase); break; } } return(tbr); }
/// <summary> /// Creates a new <see cref="CompletionRules"/> instance. /// </summary> /// <param name="dismissIfEmpty">True if the completion list should be dismissed if the user's typing causes it to filter and display no items.</param> /// <param name="dismissIfLastCharacterDeleted">True if the list should be dismissed when the user deletes the last character in the span.</param> /// <param name="defaultCommitCharacters">The default set of typed characters that cause the selected item to be committed.</param> /// <param name="defaultEnterKeyRule">The default rule that determines if the enter key is passed through to the editor after the selected item has been committed.</param> public static CompletionRules Create( bool dismissIfEmpty, bool dismissIfLastCharacterDeleted, ImmutableArray <char> defaultCommitCharacters, EnterKeyRule defaultEnterKeyRule) { return(Create(dismissIfEmpty, dismissIfLastCharacterDeleted, defaultCommitCharacters, defaultEnterKeyRule, SnippetsRule.Default)); }
/// <summary> /// Creates a new <see cref="CompletionRules"/> instance. /// </summary> /// <param name="dismissIfEmpty">True if the completion list should be dismissed if the user's typing causes it to filter and display no items.</param> /// <param name="dismissIfLastCharacterDeleted">True if the list should be dismissed when the user deletes the last character in the span.</param> /// <param name="defaultCommitCharacters">The default set of typed characters that cause the selected item to be committed.</param> /// <param name="defaultEnterKeyRule">The default rule that determines if the enter key is passed through to the editor after the selected item has been committed.</param> public static CompletionRules Create( bool dismissIfEmpty, bool dismissIfLastCharacterDeleted, ImmutableArray<char> defaultCommitCharacters, EnterKeyRule defaultEnterKeyRule) { return Create(dismissIfEmpty, dismissIfLastCharacterDeleted, defaultCommitCharacters, defaultEnterKeyRule, SnippetsRule.Default); }
private CompletionRules( bool dismissIfEmpty, bool dismissIfLastCharacterDeleted, ImmutableArray <char> defaultCommitCharacters, EnterKeyRule defaultEnterKeyRule) { this.DismissIfEmpty = dismissIfEmpty; this.DismissIfLastCharacterDeleted = dismissIfLastCharacterDeleted; this.DefaultCommitCharacters = defaultCommitCharacters.IsDefault ? ImmutableArray <char> .Empty : defaultCommitCharacters; this.DefaultEnterKeyRule = defaultEnterKeyRule; }
/// <summary> /// Creates a new <see cref="CompletionItemRules"/> instance--internal for TypeScript. /// </summary> /// <param name="filterCharacterRules">Rules about which keys typed are used to filter the list of completion items.</param> /// <param name="commitCharacterRules">Rules about which keys typed caused the completion item to be committed.</param> /// <param name="enterKeyRule">Rule about whether the enter key is passed through to the editor after the selected item has been committed.</param> /// <param name="formatOnCommit">True if the modified text should be formatted automatically.</param> /// <param name="preselect">True if the related completion item should be initially selected.</param> /// <returns></returns> internal static CompletionItemRules Create( ImmutableArray <CharacterSetModificationRule> filterCharacterRules, ImmutableArray <CharacterSetModificationRule> commitCharacterRules, EnterKeyRule enterKeyRule, bool formatOnCommit, bool preselect) { var matchPriority = preselect ? Completion.MatchPriority.Preselect : Completion.MatchPriority.Default; return(CompletionItemRules.Create(filterCharacterRules, commitCharacterRules, enterKeyRule, formatOnCommit, matchPriority)); }
private CompletionRules( bool dismissIfEmpty, bool dismissIfLastCharacterDeleted, ImmutableArray<char> defaultCommitCharacters, EnterKeyRule defaultEnterKeyRule) { this.DismissIfEmpty = dismissIfEmpty; this.DismissIfLastCharacterDeleted = dismissIfLastCharacterDeleted; this.DefaultCommitCharacters = defaultCommitCharacters.IsDefault ? ImmutableArray<char>.Empty : defaultCommitCharacters; this.DefaultEnterKeyRule = defaultEnterKeyRule; }
/// <summary> /// Creates a new <see cref="CompletionRules"/> instance. /// </summary> /// <param name="dismissIfEmpty">True if the completion list should be dismissed if the user's typing causes it to filter and display no items.</param> /// <param name="dismissIfLastCharacterDeleted">True if the list should be dismissed when the user deletes the last character in the span.</param> /// <param name="defaultCommitCharacters">The default set of typed characters that cause the selected item to be committed.</param> /// <param name="defaultEnterKeyRule">The default rule that determines if the enter key is passed through to the editor after the selected item has been committed.</param> /// <returns></returns> public static CompletionRules Create( bool dismissIfEmpty = false, bool dismissIfLastCharacterDeleted = false, ImmutableArray<char> defaultCommitCharacters = default(ImmutableArray<char>), EnterKeyRule defaultEnterKeyRule = EnterKeyRule.Default) { return new CompletionRules( dismissIfEmpty: dismissIfEmpty, dismissIfLastCharacterDeleted: dismissIfLastCharacterDeleted, defaultCommitCharacters: defaultCommitCharacters, defaultEnterKeyRule: defaultEnterKeyRule); }
/// <summary> /// Creates a new <see cref="CompletionItemRules"/> instance. /// </summary> /// <param name="filterCharacterRules">Rules about which keys typed are used to filter the list of completion items.</param> /// <param name="commitCharacterRules">Rules about which keys typed caused the completion item to be committed.</param> /// <param name="enterKeyRule">Rule about whether the enter key is passed through to the editor after the selected item has been committed.</param> /// <param name="formatOnCommit">True if the modified text should be formatted automatically.</param> /// <param name="matchPriority">True if the related completion item should be initially selected.</param> /// <returns></returns> public static CompletionItemRules Create( ImmutableArray <CharacterSetModificationRule> filterCharacterRules, ImmutableArray <CharacterSetModificationRule> commitCharacterRules, EnterKeyRule enterKeyRule, bool formatOnCommit, int?matchPriority) { return(Create( filterCharacterRules, commitCharacterRules, enterKeyRule, formatOnCommit, matchPriority, selectionBehavior: CompletionItemSelectionBehavior.Default)); }
/// <summary> /// Creates a new <see cref="CompletionRules"/> instance. /// </summary> /// <param name="dismissIfEmpty">True if the completion list should be dismissed if the user's typing causes it to filter and display no items.</param> /// <param name="dismissIfLastCharacterDeleted">True if the list should be dismissed when the user deletes the last character in the span.</param> /// <param name="defaultCommitCharacters">The default set of typed characters that cause the selected item to be committed.</param> /// <param name="defaultEnterKeyRule">The default rule that determines if the enter key is passed through to the editor after the selected item has been committed.</param> /// <returns></returns> public static CompletionRules Create( bool dismissIfEmpty = false, bool dismissIfLastCharacterDeleted = false, ImmutableArray <char> defaultCommitCharacters = default(ImmutableArray <char>), EnterKeyRule defaultEnterKeyRule = EnterKeyRule.Default) { return(new CompletionRules( dismissIfEmpty: dismissIfEmpty, dismissIfLastCharacterDeleted: dismissIfLastCharacterDeleted, defaultCommitCharacters: defaultCommitCharacters, defaultEnterKeyRule: defaultEnterKeyRule)); }
private CompletionItemRules( ImmutableArray<CharacterSetModificationRule> filterCharacterRules, ImmutableArray<CharacterSetModificationRule> commitCharacterRules, EnterKeyRule enterKeyRule, bool formatOnCommit, bool preselect) { this.FilterCharacterRules = filterCharacterRules.IsDefault ? ImmutableArray<CharacterSetModificationRule>.Empty : filterCharacterRules; this.CommitCharacterRules = commitCharacterRules.IsDefault ? ImmutableArray<CharacterSetModificationRule>.Empty : commitCharacterRules; this.EnterKeyRule = enterKeyRule; this.FormatOnCommit = formatOnCommit; this.Preselect = preselect; }
private CompletionItemRules( ImmutableArray <CharacterSetModificationRule> filterCharacterRules, ImmutableArray <CharacterSetModificationRule> commitCharacterRules, EnterKeyRule enterKeyRule, bool formatOnCommit, int matchPriority) { this.FilterCharacterRules = filterCharacterRules.IsDefault ? ImmutableArray <CharacterSetModificationRule> .Empty : filterCharacterRules; this.CommitCharacterRules = commitCharacterRules.IsDefault ? ImmutableArray <CharacterSetModificationRule> .Empty : commitCharacterRules; this.EnterKeyRule = enterKeyRule; this.FormatOnCommit = formatOnCommit; this.MatchPriority = matchPriority; }
private CompletionItemRules( ImmutableArray <CharacterSetModificationRule> filterCharacterRules, ImmutableArray <CharacterSetModificationRule> commitCharacterRules, EnterKeyRule enterKeyRule, bool formatOnCommit, bool preselect) { this.FilterCharacterRules = filterCharacterRules.IsDefault ? ImmutableArray <CharacterSetModificationRule> .Empty : filterCharacterRules; this.CommitCharacterRules = commitCharacterRules.IsDefault ? ImmutableArray <CharacterSetModificationRule> .Empty : commitCharacterRules; this.EnterKeyRule = enterKeyRule; this.FormatOnCommit = formatOnCommit; this.Preselect = preselect; }
private CompletionRules( bool dismissIfEmpty, bool dismissIfLastCharacterDeleted, ImmutableArray <char> defaultCommitCharacters, EnterKeyRule defaultEnterKeyRule, SnippetsRule snippetsRule) { DismissIfEmpty = dismissIfEmpty; DismissIfLastCharacterDeleted = dismissIfLastCharacterDeleted; DefaultCommitCharacters = defaultCommitCharacters.NullToEmpty(); DefaultEnterKeyRule = defaultEnterKeyRule; SnippetsRule = snippetsRule; }
private CompletionRules( bool dismissIfEmpty, bool dismissIfLastCharacterDeleted, ImmutableArray<char> defaultCommitCharacters, EnterKeyRule defaultEnterKeyRule, SnippetsRule snippetsRule) { this.DismissIfEmpty = dismissIfEmpty; this.DismissIfLastCharacterDeleted = dismissIfLastCharacterDeleted; this.DefaultCommitCharacters = defaultCommitCharacters.NullToEmpty(); this.DefaultEnterKeyRule = defaultEnterKeyRule; this.SnippetsRule = snippetsRule; }
private CompletionItemRules( ImmutableArray <CharacterSetModificationRule> filterCharacterRules, ImmutableArray <CharacterSetModificationRule> commitCharacterRules, EnterKeyRule enterKeyRule, bool formatOnCommit, int matchPriority, CompletionItemSelectionBehavior selectionBehavior) { FilterCharacterRules = filterCharacterRules.NullToEmpty(); CommitCharacterRules = commitCharacterRules.NullToEmpty(); EnterKeyRule = enterKeyRule; FormatOnCommit = formatOnCommit; MatchPriority = matchPriority; SelectionBehavior = selectionBehavior; }
private CompletionItemRules( ImmutableArray<CharacterSetModificationRule> filterCharacterRules, ImmutableArray<CharacterSetModificationRule> commitCharacterRules, EnterKeyRule enterKeyRule, bool formatOnCommit, int matchPriority, CompletionItemSelectionBehavior selectionBehavior) { FilterCharacterRules = filterCharacterRules.IsDefault ? ImmutableArray<CharacterSetModificationRule>.Empty : filterCharacterRules; CommitCharacterRules = commitCharacterRules.IsDefault ? ImmutableArray<CharacterSetModificationRule>.Empty : commitCharacterRules; EnterKeyRule = enterKeyRule; FormatOnCommit = formatOnCommit; MatchPriority = matchPriority; SelectionBehavior = selectionBehavior; }
/// <summary> /// Creates a new <see cref="CompletionItemRules"/> instance. /// </summary> /// <param name="filterCharacterRules">Rules about which keys typed are used to filter the list of completion items.</param> /// <param name="commitCharacterRules">Rules about which keys typed caused the completion item to be committed.</param> /// <param name="enterKeyRule">Rule about whether the enter key is passed through to the editor after the selected item has been committed.</param> /// <param name="formatOnCommit">True if the modified text should be formatted automatically.</param> /// <param name="preselect">True if the related completion item should be initially selected.</param> /// <returns></returns> public static CompletionItemRules Create( ImmutableArray <CharacterSetModificationRule> filterCharacterRules = default(ImmutableArray <CharacterSetModificationRule>), ImmutableArray <CharacterSetModificationRule> commitCharacterRules = default(ImmutableArray <CharacterSetModificationRule>), EnterKeyRule enterKeyRule = EnterKeyRule.Default, bool formatOnCommit = false, bool preselect = false) { if (filterCharacterRules.IsDefaultOrEmpty && commitCharacterRules.IsDefaultOrEmpty && enterKeyRule == Default.EnterKeyRule && formatOnCommit == Default.FormatOnCommit && preselect == Default.Preselect) { return(Default); } else { return(new CompletionItemRules(filterCharacterRules, commitCharacterRules, enterKeyRule, formatOnCommit, preselect)); } }
/// <summary> /// Creates a new <see cref="CompletionItemRules"/> instance. /// </summary> /// <param name="filterCharacterRules">Rules about which keys typed are used to filter the list of completion items.</param> /// <param name="commitCharacterRules">Rules about which keys typed caused the completion item to be committed.</param> /// <param name="enterKeyRule">Rule about whether the enter key is passed through to the editor after the selected item has been committed.</param> /// <param name="formatOnCommit">True if the modified text should be formatted automatically.</param> /// <param name="matchPriority">True if the related completion item should be initially selected.</param> /// <returns></returns> public static CompletionItemRules Create( ImmutableArray <CharacterSetModificationRule> filterCharacterRules = default(ImmutableArray <CharacterSetModificationRule>), ImmutableArray <CharacterSetModificationRule> commitCharacterRules = default(ImmutableArray <CharacterSetModificationRule>), EnterKeyRule enterKeyRule = EnterKeyRule.Default, bool formatOnCommit = false, int?matchPriority = null) { if (filterCharacterRules.IsDefaultOrEmpty && commitCharacterRules.IsDefaultOrEmpty && enterKeyRule == Default.EnterKeyRule && formatOnCommit == Default.FormatOnCommit && matchPriority == Default.MatchPriority) { return(Default); } else { return(new CompletionItemRules(filterCharacterRules, commitCharacterRules, enterKeyRule, formatOnCommit, matchPriority ?? Completion.MatchPriority.Default)); } }
/// <summary> /// Creates a new <see cref="CompletionItemRules"/> instance. /// </summary> /// <param name="filterCharacterRules">Rules about which keys typed are used to filter the list of completion items.</param> /// <param name="commitCharacterRules">Rules about which keys typed caused the completion item to be committed.</param> /// <param name="enterKeyRule">Rule about whether the enter key is passed through to the editor after the selected item has been committed.</param> /// <param name="formatOnCommit">True if the modified text should be formatted automatically.</param> /// <param name="preselect">True if the related completion item should be initially selected.</param> /// <returns></returns> public static CompletionItemRules Create( ImmutableArray<CharacterSetModificationRule> filterCharacterRules = default(ImmutableArray<CharacterSetModificationRule>), ImmutableArray<CharacterSetModificationRule> commitCharacterRules = default(ImmutableArray<CharacterSetModificationRule>), EnterKeyRule enterKeyRule = EnterKeyRule.Default, bool formatOnCommit = false, bool preselect = false) { if (filterCharacterRules.IsDefaultOrEmpty && commitCharacterRules.IsDefaultOrEmpty && enterKeyRule == Default.EnterKeyRule && formatOnCommit == Default.FormatOnCommit && preselect == Default.Preselect) { return Default; } else { return new CompletionItemRules(filterCharacterRules, commitCharacterRules, enterKeyRule, formatOnCommit, preselect); } }
/// <summary> /// Creates a new <see cref="CompletionItemRules"/> instance. /// </summary> /// <param name="filterCharacterRules">Rules about which keys typed are used to filter the list of completion items.</param> /// <param name="commitCharacterRules">Rules about which keys typed caused the completion item to be committed.</param> /// <param name="enterKeyRule">Rule about whether the enter key is passed through to the editor after the selected item has been committed.</param> /// <param name="formatOnCommit">True if the modified text should be formatted automatically.</param> /// <param name="matchPriority">True if the related completion item should be initially selected.</param> /// <param name="selectionBehavior">How this item should be selected if no text has been typed after the completion list is brought up.</param> /// <returns></returns> public static CompletionItemRules Create( ImmutableArray <CharacterSetModificationRule> filterCharacterRules = default(ImmutableArray <CharacterSetModificationRule>), ImmutableArray <CharacterSetModificationRule> commitCharacterRules = default(ImmutableArray <CharacterSetModificationRule>), EnterKeyRule enterKeyRule = EnterKeyRule.Default, bool formatOnCommit = false, int?matchPriority = null, CompletionItemSelectionBehavior selectionBehavior = CompletionItemSelectionBehavior.Default) { if (filterCharacterRules.IsDefaultOrEmpty && commitCharacterRules.IsDefaultOrEmpty && enterKeyRule == Default.EnterKeyRule && formatOnCommit == Default.FormatOnCommit && matchPriority.GetValueOrDefault() == Default.MatchPriority && selectionBehavior == Default.SelectionBehavior) { return(Default); } else { return(new CompletionItemRules( filterCharacterRules, commitCharacterRules, enterKeyRule, formatOnCommit, matchPriority.GetValueOrDefault(), selectionBehavior)); } }
/// <summary> /// Creates a new <see cref="CompletionItemRules"/> instance. /// </summary> /// <param name="filterCharacterRules">Rules about which keys typed are used to filter the list of completion items.</param> /// <param name="commitCharacterRules">Rules about which keys typed caused the completion item to be committed.</param> /// <param name="enterKeyRule">Rule about whether the enter key is passed through to the editor after the selected item has been committed.</param> /// <param name="formatOnCommit">True if the modified text should be formatted automatically.</param> /// <param name="matchPriority">True if the related completion item should be initially selected.</param> /// <returns></returns> public static CompletionItemRules Create( ImmutableArray<CharacterSetModificationRule> filterCharacterRules, ImmutableArray<CharacterSetModificationRule> commitCharacterRules, EnterKeyRule enterKeyRule, bool formatOnCommit, int? matchPriority) { return Create( filterCharacterRules, commitCharacterRules, enterKeyRule, formatOnCommit, matchPriority, selectionBehavior: CompletionItemSelectionBehavior.Default); }
protected async Task VerifySendEnterThroughToEnterAsync(string initialMarkup, string textTypedSoFar, EnterKeyRule sendThroughEnterOption, bool expected, SourceCodeKind sourceCodeKind = SourceCodeKind.Regular) { using var workspace = TestWorkspace.CreateCSharp(initialMarkup, exportProvider: ExportProvider); var hostDocument = workspace.DocumentWithCursor; workspace.OnDocumentSourceCodeKindChanged(hostDocument.Id, sourceCodeKind); var documentId = workspace.GetDocumentId(hostDocument); var document = workspace.CurrentSolution.GetDocument(documentId); var position = hostDocument.CursorPosition.Value; workspace.TryApplyChanges(workspace.CurrentSolution.WithOptions(workspace.Options .WithChangedOption( CompletionOptions.EnterKeyBehavior, LanguageNames.CSharp, sendThroughEnterOption))); var service = GetCompletionService(document.Project); var completionList = await GetCompletionListAsync(service, document, position, RoslynTrigger.Invoke); var item = completionList.Items.First(i => (i.DisplayText + i.DisplayTextSuffix).StartsWith(textTypedSoFar)); Assert.Equal(expected, CommitManager.SendEnterThroughToEditor(service.GetRules(), item, textTypedSoFar)); }
/// <summary> /// Creates a copy of this <see cref="CompletionRules"/> with the <see cref="DefaultEnterKeyRule"/> property changed. /// </summary> public CompletionRules WithDefaultEnterKeyRule(EnterKeyRule defaultEnterKeyRule) { return With(defaultEnterKeyRule: defaultEnterKeyRule); }
protected async Task VerifySendEnterThroughToEnterAsync(string initialMarkup, string textTypedSoFar, EnterKeyRule sendThroughEnterOption, bool expected) { using (var workspace = TestWorkspace.CreateCSharp(initialMarkup)) { var hostDocument = workspace.DocumentWithCursor; var documentId = workspace.GetDocumentId(hostDocument); var document = workspace.CurrentSolution.GetDocument(documentId); var position = hostDocument.CursorPosition.Value; workspace.Options = workspace.Options.WithChangedOption( CompletionOptions.EnterKeyBehavior, LanguageNames.CSharp, sendThroughEnterOption); var service = GetCompletionService(workspace); var completionList = await GetCompletionListAsync(service, document, position, CompletionTrigger.Invoke); var item = completionList.Items.First(i => (i.DisplayText + i.DisplayTextSuffix).StartsWith(textTypedSoFar)); Assert.Equal(expected, CommitManager.SendEnterThroughToEditor(service.GetRules(), item, textTypedSoFar)); } }
/// <summary> /// Creates a copy of this <see cref="CompletionItemRules"/> with the <see cref="EnterKeyRule"/> property changed. /// </summary> public CompletionItemRules WithEnterKeyRule(EnterKeyRule enterKeyRule) { return this.With(enterKeyRule: enterKeyRule); }
[InlineData(EnterKeyRule.Always)] // note: GAC completion helper uses its own EnterKeyRule public async Task SendEnterThroughToEditorTest(EnterKeyRule enterKeyRule) { await VerifySendEnterThroughToEnterAsync("#r \"System$$", "System", enterKeyRule, expected : false, SourceCodeKind.Script); }
/// <summary> /// Creates a copy of this <see cref="CompletionRules"/> with the <see cref="DefaultEnterKeyRule"/> property changed. /// </summary> public CompletionRules WithDefaultEnterKeyRule(EnterKeyRule defaultEnterKeyRule) { return(With(defaultEnterKeyRule: defaultEnterKeyRule)); }
/// <summary> /// Creates a new <see cref="CompletionItemRules"/> instance--internal for TypeScript. /// </summary> /// <param name="filterCharacterRules">Rules about which keys typed are used to filter the list of completion items.</param> /// <param name="commitCharacterRules">Rules about which keys typed caused the completion item to be committed.</param> /// <param name="enterKeyRule">Rule about whether the enter key is passed through to the editor after the selected item has been committed.</param> /// <param name="formatOnCommit">True if the modified text should be formatted automatically.</param> /// <param name="preselect">True if the related completion item should be initially selected.</param> /// <returns></returns> internal static CompletionItemRules Create( ImmutableArray<CharacterSetModificationRule> filterCharacterRules, ImmutableArray<CharacterSetModificationRule> commitCharacterRules, EnterKeyRule enterKeyRule, bool formatOnCommit, bool preselect) { var matchPriority = preselect ? Completion.MatchPriority.Preselect : Completion.MatchPriority.Default; return CompletionItemRules.Create(filterCharacterRules, commitCharacterRules, enterKeyRule, formatOnCommit, matchPriority); }
/// <summary> /// Creates a copy of this <see cref="CompletionItemRules"/> with the <see cref="EnterKeyRule"/> property changed. /// </summary> public CompletionItemRules WithEnterKeyRule(EnterKeyRule enterKeyRule) { return(this.With(enterKeyRule: enterKeyRule)); }
public CompletionRules WithDefaultEnterKeyRule(EnterKeyRule defaultEnterKeyRule) => With(defaultEnterKeyRule: defaultEnterKeyRule);
/// <summary> /// Creates a new <see cref="CompletionItemRules"/> instance. /// </summary> /// <param name="filterCharacterRules">Rules about which keys typed are used to filter the list of completion items.</param> /// <param name="commitCharacterRules">Rules about which keys typed caused the completion item to be committed.</param> /// <param name="enterKeyRule">Rule about whether the enter key is passed through to the editor after the selected item has been committed.</param> /// <param name="formatOnCommit">True if the modified text should be formatted automatically.</param> /// <param name="matchPriority">True if the related completion item should be initially selected.</param> /// <param name="selectionBehavior">How this item should be selected if no text has been typed after the completion list is brought up.</param> /// <returns></returns> public static CompletionItemRules Create( ImmutableArray<CharacterSetModificationRule> filterCharacterRules = default(ImmutableArray<CharacterSetModificationRule>), ImmutableArray<CharacterSetModificationRule> commitCharacterRules = default(ImmutableArray<CharacterSetModificationRule>), EnterKeyRule enterKeyRule = EnterKeyRule.Default, bool formatOnCommit = false, int? matchPriority = null, CompletionItemSelectionBehavior selectionBehavior = CompletionItemSelectionBehavior.Default) { if (filterCharacterRules.IsDefaultOrEmpty && commitCharacterRules.IsDefaultOrEmpty && enterKeyRule == Default.EnterKeyRule && formatOnCommit == Default.FormatOnCommit && matchPriority.GetValueOrDefault() == Default.MatchPriority && selectionBehavior == Default.SelectionBehavior) { return Default; } else { return new CompletionItemRules( filterCharacterRules, commitCharacterRules, enterKeyRule, formatOnCommit, matchPriority.GetValueOrDefault(), selectionBehavior); } }