Skip to content

Commit

Permalink
feat: improve ghost text render (#4102)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricbet authored Oct 17, 2024
1 parent c2689bd commit 0cace90
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/ai-native/src/browser/ai-core.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,8 @@ export class AINativeBrowserContribution
execute: async (visible: boolean) => {
if (!visible) {
this.aiCompletionsService.hideStatusBarItem();
this.aiInlineCompletionsProvider.setVisibleCompletion(false);
this.aiInlineCompletionsProvider.cancelRequest();
this.aiCompletionsService.setVisibleCompletion(false);
}
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
SuggestItemInfo,
SuggestWidgetAdaptor,
} from '@opensumi/monaco-editor-core/esm/vs/editor/contrib/inlineCompletions/browser/suggestWidgetInlineCompletionProvider';
import { SuggestController } from '@opensumi/monaco-editor-core/esm/vs/editor/contrib/suggest/browser/suggestController';
import { ContextKeyExpr } from '@opensumi/monaco-editor-core/esm/vs/platform/contextkey/common/contextkey';

import { AINativeContextKey } from '../../contextkey/ai-native.contextkey.service';
Expand Down Expand Up @@ -129,6 +130,19 @@ export class IntelligentCompletionsController extends BaseAIMonacoEditorControll
}
}),
);

observableDisposable.addDispose(
autorun((reader) => {
const state = inlineCompletionsController.model.read(reader)?.state.read(reader);
const suggestController = SuggestController.get(this.monacoEditor);
// 当阴影字符超出一行的时候,强制让 suggest 面板向上展示,避免遮挡补全内容
if (state && state.primaryGhostText?.lineCount >= 2) {
suggestController?.forceRenderingAbove();
} else {
suggestController?.stopForceRenderingAbove();
}
}),
);
}
};

Expand Down

0 comments on commit 0cace90

Please sign in to comment.