Skip to content

Commit

Permalink
fix: #2492
Browse files Browse the repository at this point in the history
  • Loading branch information
Jocs committed Sep 10, 2024
1 parent 430390e commit 9c0575d
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions packages/sheets-formula/src/controllers/prompt.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export class PromptController extends Disposable {
@IRefSelectionsService private readonly _refSelectionsService: SheetsSelectionsService,
@IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,
@Inject(IDescriptionService) private readonly _descriptionService: IDescriptionService,
@Inject(DocSelectionManagerService) private readonly _textSelectionManagerService: DocSelectionManagerService,
@Inject(DocSelectionManagerService) private readonly _docSelectionManagerService: DocSelectionManagerService,
@IContextMenuService private readonly _contextMenuService: IContextMenuService,
@IEditorService private readonly _editorService: IEditorService,
@ILayoutService private readonly _layoutService: ILayoutService
Expand Down Expand Up @@ -254,7 +254,7 @@ export class PromptController extends Disposable {

private _initialCursorSync() {
this.disposeWithMe(
this._textSelectionManagerService.textSelection$.subscribe((params) => {
this._docSelectionManagerService.textSelection$.subscribe((params) => {
if (params?.unitId == null) {
return;
}
Expand Down Expand Up @@ -519,7 +519,7 @@ export class PromptController extends Disposable {
private _initAcceptFormula() {
this.disposeWithMe(
this._formulaPromptService.acceptFormulaName$.subscribe((formulaString: string) => {
const activeRange = this._textSelectionManagerService.getActiveTextRange();
const activeRange = this._docSelectionManagerService.getActiveTextRange();

if (activeRange == null) {
this._hideFunctionPanel();
Expand Down Expand Up @@ -585,7 +585,7 @@ export class PromptController extends Disposable {
}

private _changeFunctionPanelState() {
const activeRange = this._textSelectionManagerService.getActiveTextRange();
const activeRange = this._docSelectionManagerService.getActiveTextRange();

if (activeRange == null) {
this._hideFunctionPanel();
Expand Down Expand Up @@ -684,7 +684,7 @@ export class PromptController extends Disposable {
* @returns Return the character under the current cursor in the editor.
*/
private _getCurrentChar() {
const activeRange = this._textSelectionManagerService.getActiveTextRange();
const activeRange = this._docSelectionManagerService.getActiveTextRange();

if (activeRange == null) {
return;
Expand Down Expand Up @@ -813,7 +813,7 @@ export class PromptController extends Disposable {

this._formulaPromptService.setSequenceNodes(lastSequenceNodes);

const activeRange = this._textSelectionManagerService.getActiveTextRange();
const activeRange = this._docSelectionManagerService.getActiveTextRange();

if (activeRange == null) {
return;
Expand Down Expand Up @@ -1215,7 +1215,7 @@ export class PromptController extends Disposable {
// Get theme color from prompt formula editor when creating a new selection.
this._allSelectionRenderServices.forEach((r) => this._updateRefSelectionStyle(r, this._isSelectionMovingRefSelections));

const activeRange = this._textSelectionManagerService.getActiveTextRange();
const activeRange = this._docSelectionManagerService.getActiveTextRange();
if (activeRange == null) {
return;
}
Expand Down Expand Up @@ -1266,7 +1266,7 @@ export class PromptController extends Disposable {
options: { fromSelection },
});
// The ReplaceContentCommand has canceled the selection operation, so it needs to be triggered externally once.
this._textSelectionManagerService.replaceTextRanges([
this._docSelectionManagerService.replaceTextRanges([
{
startOffset: textSelectionOffset + 1 - offset,
endOffset: textSelectionOffset + 1 - offset,
Expand All @@ -1275,7 +1275,7 @@ export class PromptController extends Disposable {
], true, { fromSelection });
} else {
this._updateEditorModel(`${formulaString}\r\n`, textRuns);
this._textSelectionManagerService.replaceTextRanges([
this._docSelectionManagerService.replaceTextRanges([
{
startOffset: textSelectionOffset + 1 - offset,
endOffset: textSelectionOffset + 1 - offset,
Expand All @@ -1287,9 +1287,7 @@ export class PromptController extends Disposable {
/**
* After selecting the formula, allow the editor to continue entering content.
*/
setTimeout(() => {
this._layoutService.focus();
}, 0);
this._layoutService.focus();
}

private _fitEditorSize() {
Expand Down Expand Up @@ -1840,7 +1838,7 @@ export class PromptController extends Disposable {
* Absolute range, triggered by F4
*/
private _changeRefString() {
const activeRange = this._textSelectionManagerService.getActiveTextRange();
const activeRange = this._docSelectionManagerService.getActiveTextRange();

if (activeRange == null) {
return;
Expand Down

0 comments on commit 9c0575d

Please sign in to comment.