tweak inline chat hint (#234821)

* make editor readonly and disable squiggle while inline chat shows reply

https://github.com/microsoft/vscode/issues/226160

* tweak inline chat hint

only show on intented empty lines, hide when command run

* fix tests (only disable squiggle, not readonlyness)
This commit is contained in:
Johannes Rieken
2024-11-28 12:58:47 +01:00
committed by GitHub
parent 180a8271e1
commit 1994ebabef
4 changed files with 26 additions and 7 deletions

View File

@@ -17,6 +17,7 @@ import { StopWatch } from '../../../../base/common/stopwatch.js';
import { assertType } from '../../../../base/common/types.js';
import { generateUuid } from '../../../../base/common/uuid.js';
import { ICodeEditor, isCodeEditor } from '../../../../editor/browser/editorBrowser.js';
import { EditorOption } from '../../../../editor/common/config/editorOptions.js';
import { IPosition, Position } from '../../../../editor/common/core/position.js';
import { IRange, Range } from '../../../../editor/common/core/range.js';
import { ISelection, Selection, SelectionDirection } from '../../../../editor/common/core/selection.js';
@@ -591,8 +592,19 @@ export class InlineChatController implements IEditorContribution {
const progressiveEditsClock = StopWatch.create();
const progressiveEditsQueue = new Queue();
let next: State.WAIT_FOR_INPUT | State.SHOW_REQUEST | State.CANCEL | State.PAUSE | State.ACCEPT = State.WAIT_FOR_INPUT;
// disable typing and squiggles while streaming a reply
const origDeco = this._editor.getOption(EditorOption.renderValidationDecorations);
this._editor.updateOptions({
renderValidationDecorations: 'off'
});
store.add(toDisposable(() => {
this._editor.updateOptions({
renderValidationDecorations: origDeco
});
}));
let next: State.WAIT_FOR_INPUT | State.SHOW_REQUEST | State.CANCEL | State.PAUSE | State.ACCEPT = State.WAIT_FOR_INPUT;
store.add(Event.once(this._messages.event)(message => {
this._log('state=_makeRequest) message received', message);
this._chatService.cancelCurrentRequestForSession(chatModel.sessionId);

View File

@@ -184,6 +184,12 @@ export class InlineChatHintsController extends Disposable implements IEditorCont
const ghostCtrl = InlineCompletionsController.get(editor);
this._store.add(commandService.onWillExecuteCommand(e => {
if (e.commandId === _inlineChatActionId || e.commandId === ACTION_START) {
this.hide();
}
}));
this._store.add(this._editor.onMouseDown(e => {
if (e.target.type !== MouseTargetType.CONTENT_TEXT) {
return;
@@ -227,12 +233,13 @@ export class InlineChatHintsController extends Disposable implements IEditorCont
const visible = this._visibilityObs.read(r);// || this._ctxMenuVisibleObs.read(r);
const isEol = model.getLineMaxColumn(position.lineNumber) === position.column;
const isWhitespace = model.getLineLastNonWhitespaceColumn(position.lineNumber) === 0 && model.getValueLength() > 0;
const isWhitespace = model.getLineLastNonWhitespaceColumn(position.lineNumber) === 0 && model.getValueLength() > 0 && position.column > 1;
const shouldShow = (isWhitespace && _configurationService.getValue(InlineChatConfigKeys.LineEmptyHint))
|| (visible && isEol && _configurationService.getValue(InlineChatConfigKeys.LineSuffixHint));
if (isWhitespace && !_configurationService.getValue(InlineChatConfigKeys.LineEmptyHint)) {
return undefined;
}
if (!shouldShow) {
if (!visible || !isEol || !_configurationService.getValue(InlineChatConfigKeys.LineSuffixHint)) {
return undefined;
}