mirror of
https://github.com/voideditor/void
synced 2026-05-24 09:58:23 +00:00
fix cmd+k tabbing
This commit is contained in:
parent
e48e798afc
commit
3abafa76ec
2 changed files with 42 additions and 2 deletions
|
|
@ -61,6 +61,43 @@ registerColor('void.sweepIdxBG', configOfBG(sweepIdxBG), '', true);
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
const getLeadingWhitespacePx = (editor: ICodeEditor, startLine: number): number => {
|
||||
|
||||
const model = editor.getModel();
|
||||
if (!model) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get the line content, defaulting to empty string if line doesn't exist
|
||||
const lineContent = model.getLineContent(startLine) || '';
|
||||
|
||||
// Find the first non-whitespace character
|
||||
const firstNonWhitespaceIndex = lineContent.search(/\S/);
|
||||
|
||||
// Extract leading whitespace, handling case where line is all whitespace
|
||||
const leadingWhitespace = firstNonWhitespaceIndex === -1
|
||||
? lineContent
|
||||
: lineContent.slice(0, firstNonWhitespaceIndex);
|
||||
|
||||
// Get font information from editor render options
|
||||
const { tabSize: numSpacesInTab } = model.getFormattingOptions();
|
||||
const spaceWidth = editor.getOption(EditorOption.fontInfo).spaceWidth;
|
||||
const tabWidth = numSpacesInTab * spaceWidth;
|
||||
|
||||
let paddingLeft = 0;
|
||||
for (const char of leadingWhitespace) {
|
||||
if (char === '\t') {
|
||||
paddingLeft += tabWidth
|
||||
} else if (char === ' ') {
|
||||
paddingLeft += spaceWidth;
|
||||
}
|
||||
}
|
||||
|
||||
return paddingLeft;
|
||||
};
|
||||
|
||||
// similar to ServiceLLM
|
||||
export type StartApplyingOpts = {
|
||||
featureName: 'Ctrl+K';
|
||||
|
|
@ -400,10 +437,14 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService {
|
|||
let viewZone_: IViewZone | null = null
|
||||
const textAreaRef: { current: HTMLTextAreaElement | null } = { current: null }
|
||||
|
||||
|
||||
const paddingLeft = getLeadingWhitespacePx(editor, ctrlKZone.startLine)
|
||||
|
||||
const itemId = this._consistentEditorItemService.addToEditor(editor, () => {
|
||||
const domNode = document.createElement('div');
|
||||
domNode.style.zIndex = '1'
|
||||
domNode.style.height = 'auto'
|
||||
domNode.style.paddingLeft = `${paddingLeft}px`
|
||||
const viewZone: IViewZone = {
|
||||
afterLineNumber: ctrlKZone.startLine - 1,
|
||||
domNode: domNode,
|
||||
|
|
@ -418,7 +459,6 @@ class InlineDiffsService extends Disposable implements IInlineDiffsService {
|
|||
zoneId = accessor.addZone(viewZone)
|
||||
})
|
||||
|
||||
|
||||
// mount react
|
||||
this._instantiationService.invokeFunction(accessor => {
|
||||
mountCtrlK(domNode, accessor, {
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ export const QuickEditChat = ({
|
|||
|
||||
const keybindingString = accessor.get('IKeybindingService').lookupKeybinding(VOID_CTRL_K_ACTION_ID)?.getLabel()
|
||||
|
||||
return <div ref={sizerRef} style={{ maxWidth: 500 }} className='py-2 pl-4 w-full'>
|
||||
return <div ref={sizerRef} style={{ maxWidth: 500 }} className={`py-2 w-full`}>
|
||||
<form
|
||||
// copied from SidebarChat.tsx
|
||||
className={`
|
||||
|
|
|
|||
Loading…
Reference in a new issue