Skip to content

Commit

Permalink
Remove enable setting
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas Helming <[email protected]>
  • Loading branch information
JonasHelming committed Nov 3, 2024
1 parent 38b7477 commit 06f2bed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,12 @@ export const PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS = 'ai-features.codeCo
export const AICodeCompletionPreferencesSchema: PreferenceSchema = {
type: 'object',
properties: {
[PREF_AI_INLINE_COMPLETION_ENABLE]: {
title: AI_CORE_PREFERENCES_TITLE,
type: 'boolean',
description: 'Enable AI completions inline within any (Monaco) editor.',
default: false
},
[PREF_AI_INLINE_COMPLETION_AUTOMATIC_ENABLE]: {
title: AI_CORE_PREFERENCES_TITLE,
type: 'boolean',
description: 'Automatically trigger AI completions inline within any (Monaco) editor while editing.',
description: 'Automatically trigger AI completions inline within any (Monaco) editor while editing.\
\n\
Alternativly, you can manually trigger the code via the command "Trigger Inline Suggestion" and the default shortcut "SHIFT+Space".',
default: true
},
[PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS]: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { inject, injectable } from '@theia/core/shared/inversify';
import { AIActivationService } from '@theia/ai-core/lib/browser';
import { Disposable } from '@theia/core';
import { AICodeInlineCompletionsProvider } from './ai-code-inline-completion-provider';
import { PREF_AI_INLINE_COMPLETION_AUTOMATIC_ENABLE, PREF_AI_INLINE_COMPLETION_ENABLE, PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS } from './ai-code-completion-preference';
import { PREF_AI_INLINE_COMPLETION_AUTOMATIC_ENABLE, PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS } from './ai-code-completion-preference';
import { InlineCompletionTriggerKind } from '@theia/monaco-editor-core/esm/vs/editor/common/languages';

@injectable()
Expand Down Expand Up @@ -49,8 +49,7 @@ export class AIFrontendApplicationContribution implements FrontendApplicationCon
this.toDispose.set('inlineCompletions', handler());

this.preferenceService.onPreferenceChanged(event => {
if (event.preferenceName === PREF_AI_INLINE_COMPLETION_ENABLE
|| event.preferenceName === PREF_AI_INLINE_COMPLETION_AUTOMATIC_ENABLE
if (event.preferenceName === PREF_AI_INLINE_COMPLETION_AUTOMATIC_ENABLE
|| event.preferenceName === PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS) {
this.toDispose.get('inlineCompletions')?.dispose();
this.toDispose.set('inlineCompletions', handler());
Expand All @@ -66,18 +65,15 @@ export class AIFrontendApplicationContribution implements FrontendApplicationCon
registerKeybindings(keybindings: KeybindingRegistry): void {
keybindings.registerKeybinding({
command: 'editor.action.inlineSuggest.trigger',
keybinding: 'Ctrl+Shift+Space',
keybinding: 'Shift+Space',
when: '!editorReadonly && editorTextFocus'
});
}

protected handleInlineCompletions(): Disposable {
const enable = this.preferenceService.get<boolean>(PREF_AI_INLINE_COMPLETION_ENABLE, false) && this.activationService.isActive;

if (!enable) {
if (!this.activationService.isActive) {
return Disposable.NULL;
}

const automatic = this.preferenceService.get<boolean>(PREF_AI_INLINE_COMPLETION_AUTOMATIC_ENABLE, true);
const excludedExtensions = this.preferenceService.get<string[]>(PREF_AI_INLINE_COMPLETION_EXCLUDED_EXTENSIONS, []);

Expand Down

0 comments on commit 06f2bed

Please sign in to comment.