-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { Autowired } from '@opensumi/di'; | ||
import { Key } from '@opensumi/ide-core-browser'; | ||
import { | ||
ClientAppContribution, | ||
KeybindingContribution, | ||
KeybindingRegistry, | ||
KeybindingScope, | ||
} from '@opensumi/ide-core-browser'; | ||
import { | ||
AI_MULTI_LINE_COMPLETION_ACCEPT, | ||
AI_MULTI_LINE_COMPLETION_HIDE, | ||
} from '@opensumi/ide-core-browser/lib/ai-native/command'; | ||
import { MultiLineCompletionsIsVisible } from '@opensumi/ide-core-browser/lib/contextkey/ai-native'; | ||
import { CommandContribution, CommandRegistry, Domain } from '@opensumi/ide-core-common'; | ||
|
||
import { IntelligentCompletionsHandler } from './intelligent-completions.handler'; | ||
|
||
@Domain(ClientAppContribution, KeybindingContribution, CommandContribution) | ||
export class IntelligentCompletionsContribution | ||
Check failure on line 19 in packages/ai-native/src/browser/contrib/intelligent-completions/intelligent-completions.contribution.ts GitHub Actions / build-windows
Check failure on line 19 in packages/ai-native/src/browser/contrib/intelligent-completions/intelligent-completions.contribution.ts GitHub Actions / unittest (macos-latest, 18.x, node)
Check failure on line 19 in packages/ai-native/src/browser/contrib/intelligent-completions/intelligent-completions.contribution.ts GitHub Actions / ubuntu-latest, Node.js 20.x
Check failure on line 19 in packages/ai-native/src/browser/contrib/intelligent-completions/intelligent-completions.contribution.ts GitHub Actions / build (macos-latest, 20.x)
Check failure on line 19 in packages/ai-native/src/browser/contrib/intelligent-completions/intelligent-completions.contribution.ts GitHub Actions / unittest (macos-latest, 18.x, jsdom)
Check failure on line 19 in packages/ai-native/src/browser/contrib/intelligent-completions/intelligent-completions.contribution.ts GitHub Actions / build (ubuntu-latest, 20.x)
Check failure on line 19 in packages/ai-native/src/browser/contrib/intelligent-completions/intelligent-completions.contribution.ts GitHub Actions / unittest (ubuntu-latest, 18.x, node)
Check failure on line 19 in packages/ai-native/src/browser/contrib/intelligent-completions/intelligent-completions.contribution.ts GitHub Actions / unittest (ubuntu-latest, 18.x, jsdom)
|
||
implements ClientAppContribution, KeybindingContribution, CommandContribution | ||
{ | ||
@Autowired(IntelligentCompletionsHandler) | ||
private readonly intelligentCompletionsHandler: IntelligentCompletionsHandler; | ||
|
||
registerCommands(commands: CommandRegistry): void { | ||
commands.registerCommand(AI_MULTI_LINE_COMPLETION_HIDE, { | ||
execute: () => { | ||
this.intelligentCompletionsHandler.hide(); | ||
}, | ||
}); | ||
|
||
commands.registerCommand(AI_MULTI_LINE_COMPLETION_ACCEPT, { | ||
execute: () => { | ||
this.intelligentCompletionsHandler.accept(); | ||
}, | ||
}); | ||
} | ||
|
||
registerKeybindings(keybindings: KeybindingRegistry): void { | ||
keybindings.registerKeybinding({ | ||
command: AI_MULTI_LINE_COMPLETION_HIDE.id, | ||
keybinding: Key.ESCAPE.code, | ||
when: MultiLineCompletionsIsVisible.raw, | ||
priority: 100, | ||
}); | ||
|
||
keybindings.registerKeybinding( | ||
{ | ||
command: AI_MULTI_LINE_COMPLETION_ACCEPT.id, | ||
keybinding: Key.TAB.code, | ||
when: MultiLineCompletionsIsVisible.raw, | ||
}, | ||
KeybindingScope.USER, | ||
); | ||
} | ||
} |