-
Notifications
You must be signed in to change notification settings - Fork 404
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support trigger source code edits
- Loading branch information
Showing
6 changed files
with
92 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
packages/ai-native/src/browser/contrib/intelligent-completions/source/trigger.source.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Injectable } from '@opensumi/di'; | ||
import { ECodeEditsSourceTyping, IDisposable } from '@opensumi/ide-core-common'; | ||
import { Position } from '@opensumi/ide-monaco'; | ||
import { | ||
IObservableSignal, | ||
derived, | ||
observableSignal, | ||
runOnChangeWithStore, | ||
} from '@opensumi/ide-monaco/lib/common/observable'; | ||
|
||
import { BaseCodeEditsSource } from './base'; | ||
|
||
export interface ITriggerData { | ||
position: Position | null; | ||
} | ||
|
||
@Injectable({ multiple: true }) | ||
export class TriggerCodeEditsSource extends BaseCodeEditsSource { | ||
// 主动触发的优先级是最高的 | ||
public priority = Number.MAX_SAFE_INTEGER; | ||
|
||
public triggerSignal: IObservableSignal<void> = observableSignal(this); | ||
|
||
public mount(): IDisposable { | ||
this.addDispose( | ||
runOnChangeWithStore( | ||
derived((reader) => { | ||
this.triggerSignal.read(reader); | ||
return {}; | ||
}), | ||
() => { | ||
const position = this.monacoEditor.getPosition(); | ||
this.setBean({ | ||
typing: ECodeEditsSourceTyping.Trigger, | ||
data: { | ||
[ECodeEditsSourceTyping.Trigger]: { position }, | ||
}, | ||
}); | ||
}, | ||
), | ||
); | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters