Skip to content

Commit 07465d7

Browse files
committed
initial commit
1 parent d8e9b30 commit 07465d7

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

src/vs/editor/contrib/zoneWidget/browser/zoneWidget.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export interface IOptions {
3131
allowUnlimitedHeight?: boolean;
3232
ordinal?: number;
3333
showInHiddenAreas?: boolean;
34+
allowBehindVerticalScrollbar?: boolean;
3435
}
3536

3637
export interface IStyles {
@@ -271,7 +272,7 @@ export abstract class ZoneWidget implements IHorizontalSashLayoutProvider {
271272
}
272273

273274
protected _getWidth(info: EditorLayoutInfo): number {
274-
return info.width - info.minimap.minimapWidth - info.verticalScrollbarWidth;
275+
return info.width - info.minimap.minimapWidth - (this.options.allowBehindVerticalScrollbar ? 0 : info.verticalScrollbarWidth);
275276
}
276277

277278
private _getLeft(info: EditorLayoutInfo): number {

src/vs/workbench/contrib/inlineChat/browser/inlineChatController.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/se
3838
import { CellUri } from 'vs/workbench/contrib/notebook/common/notebookCommon';
3939
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
4040
import { Lazy } from 'vs/base/common/lazy';
41+
import { Selection } from 'vs/editor/common/core/selection';
4142

4243
export const enum State {
4344
CREATE_SESSION = 'CREATE_SESSION',
@@ -100,6 +101,7 @@ export class InlineChatController implements IEditorContribution {
100101
private _activeSession?: Session;
101102
private _strategy?: EditModeStrategy;
102103
private _ignoreModelContentChanged = false;
104+
private _selection: Selection | undefined;
103105

104106
constructor(
105107
private readonly _editor: ICodeEditor,
@@ -199,16 +201,32 @@ export class InlineChatController implements IEditorContribution {
199201
assertType(this._strategy);
200202
assertType(this._editor.hasModel());
201203

204+
const info = this._editor.getLayoutInfo();
205+
const marginWithoutIndentation = info.glyphMarginWidth + info.decorationsWidth + info.lineNumbersWidth;
206+
this._zone.value.container!.style.marginLeft = `${marginWithoutIndentation}px`;
207+
202208
let widgetPosition: Position | undefined;
203209
if (initialRender) {
210+
this._selection = this._editor.getSelection();
204211
widgetPosition = this._editor.getSelection().getEndPosition();
205212
this._zone.value.setMargins(widgetPosition);
213+
console.log('widgetPosition : ', widgetPosition);
214+
console.log('selection : ', this._editor.getSelection());
206215
} else {
207216
widgetPosition = this._strategy.getWidgetPosition() ?? this._zone.value.position ?? this._activeSession.wholeRange.value.getEndPosition();
208217
const needsMargin = this._strategy.needsMargin();
209218
if (!needsMargin) {
210219
this._zone.value.setMargins(widgetPosition, 0);
211220
}
221+
// TODO: clean up
222+
const widgetLineNumber = widgetPosition.lineNumber;
223+
if (this._selection && widgetLineNumber >= this._selection.startLineNumber && widgetLineNumber < this._selection.endLineNumber) {
224+
console.log('this._zone.value.container : ', this._zone.value.container);
225+
this._zone.value.container!.style.backgroundColor = `var(--vscode-inlineChat-regionHighlight)`;
226+
}
227+
console.log('widgetPosition : ', widgetPosition);
228+
console.log('selection : ', this._editor.getSelection());
229+
console.log('this._activeSession.wholeRange : ', this._activeSession.wholeRange);
212230
}
213231
this._zone.value.show(widgetPosition);
214232
}
@@ -283,6 +301,7 @@ export class InlineChatController implements IEditorContribution {
283301
range: this._activeSession.wholeRange.value,
284302
options: InlineChatController._decoBlock
285303
}]);
304+
console.log('wholeRangeDecoration', wholeRangeDecoration);
286305
this._sessionStore.add(toDisposable(() => wholeRangeDecoration.clear()));
287306

288307
this._zone.value.widget.updateSlashCommands(this._activeSession.session.slashCommands ?? []);

src/vs/workbench/contrib/inlineChat/browser/inlineChatWidget.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ export class InlineChatZoneWidget extends ZoneWidget {
701701
@IInstantiationService private readonly _instaService: IInstantiationService,
702702
@IContextKeyService contextKeyService: IContextKeyService,
703703
) {
704-
super(editor, { showFrame: false, showArrow: false, isAccessible: true, className: 'inline-chat-widget', keepEditorSelection: true, showInHiddenAreas: true, ordinal: 10000 + 3 });
704+
super(editor, { showFrame: false, showArrow: false, isAccessible: true, className: 'inline-chat-widget', keepEditorSelection: true, showInHiddenAreas: true, ordinal: 10000 + 3, allowBehindVerticalScrollbar: true });
705705

706706
this._ctxVisible = CTX_INLINE_CHAT_VISIBLE.bindTo(contextKeyService);
707707
this._ctxCursorPosition = CTX_INLINE_CHAT_OUTER_CURSOR_POSITION.bindTo(contextKeyService);
@@ -740,7 +740,7 @@ export class InlineChatZoneWidget extends ZoneWidget {
740740

741741

742742
protected override _doLayout(heightInPixel: number): void {
743-
743+
console.log('inside of _doLayout');
744744
const maxWidth = !this.widget.showsAnyPreview() ? 640 : Number.MAX_SAFE_INTEGER;
745745
const width = Math.min(maxWidth, this._availableSpaceGivenIndentation());
746746
this._dimension = new Dimension(width, heightInPixel);
@@ -801,12 +801,10 @@ export class InlineChatZoneWidget extends ZoneWidget {
801801
}
802802
this._indentationWidth = indentationWidth;
803803
const info = this.editor.getLayoutInfo();
804-
const marginWithoutIndentation = info.glyphMarginWidth + info.decorationsWidth + info.lineNumbersWidth;
805-
const marginWithIndentation = marginWithoutIndentation + this._indentationWidth;
806804
const isEnoughAvailableSpaceWithIndentation = this._availableSpaceGivenIndentation() > 400;
807805
this._indentationWidth = isEnoughAvailableSpaceWithIndentation ? this._indentationWidth : 0;
808-
const spaceLeft = isEnoughAvailableSpaceWithIndentation ? marginWithIndentation : marginWithoutIndentation;
809-
const spaceRight = info.minimap.minimapWidth + info.verticalScrollbarWidth;
806+
const spaceLeft = isEnoughAvailableSpaceWithIndentation ? this._indentationWidth : 0;
807+
const spaceRight = info.minimap.minimapWidth;
810808
this.widget.domNode.style.marginLeft = `${spaceLeft}px`;
811809
this.widget.domNode.style.marginRight = `${spaceRight}px`;
812810
}

0 commit comments

Comments
 (0)