backup of a working version

This commit is contained in:
Andrew 2024-11-02 20:42:08 -07:00
parent 584d026256
commit 3d629396be
4 changed files with 18 additions and 41 deletions

View file

@ -205,6 +205,8 @@ export class DiffProvider implements vscode.CodeLensProvider {
}
// update green highlighting
editor.setDecorations(
greenDecoration,

View file

@ -69,9 +69,6 @@ export function activate(context: vscode.ExtensionContext) {
const { selectionStr, filePath } = getSelection(editor)
vscode.languages.addInlineDiff(editor, 'oldText', editor.selection)
// send message to the webview (Sidebar.tsx)
sidebarWebviewProvider.webview.then(webview => webview.postMessage({ type: 'ctrl+l', selection: { selectionStr, filePath } } satisfies MessageToSidebar));
})

View file

@ -23,12 +23,11 @@ class InlineDiffService extends Disposable implements IInlineDiffService {
super();
}
public addDiff: IInlineDiffService['addDiff'] = (editor, originalText, modifiedRange) => {
// Clear existing diffs
this.removeDiffs(editor);
// green decoration
// green decoration and gutter decoration
const greenDecoration: IModelDeltaDecoration[] = [{
range: modifiedRange,
options: {
@ -36,11 +35,11 @@ class InlineDiffService extends Disposable implements IInlineDiffService {
description: 'line-insert',
isWholeLine: true,
minimap: {
color: { id: 'inlineDiff.minimapGutter.addedBackground' },
color: { id: 'minimapGutter.addedBackground' },
position: 2
},
overviewRuler: {
color: { id: 'inlineDiff.editorOverviewRuler.addedForeground' },
color: { id: 'editorOverviewRuler.addedForeground' },
position: 7
}
}
@ -57,7 +56,7 @@ class InlineDiffService extends Disposable implements IInlineDiffService {
domNode.className = 'monaco-editor view-zones line-delete monaco-mouse-cursor-text';
domNode.style.fontSize = `${fontInfo.fontSize}px`;
domNode.style.fontFamily = fontInfo.fontFamily;
domNode.style.lineHeight = `100%`;
domNode.style.lineHeight = `${fontInfo.lineHeight}px`;
// div
const lineContent = document.createElement('div');
@ -78,7 +77,7 @@ class InlineDiffService extends Disposable implements IInlineDiffService {
const viewZone: IViewZone = {
afterLineNumber: modifiedRange.startLineNumber - 1,
heightInLines: 1,
heightInLines: originalText.split('\n').length + 1,
domNode: domNode,
suppressMouseDown: true,
marginDomNode: this.createGutterElement()
@ -90,13 +89,14 @@ class InlineDiffService extends Disposable implements IInlineDiffService {
});
}
// gutter is the thing to the left
private createGutterElement(): HTMLElement {
const gutterDiv = document.createElement('div');
gutterDiv.className = 'inline-diff-gutter';
const minusDiv = document.createElement('div');
minusDiv.className = 'inline-diff-deleted-gutter';
minusDiv.textContent = '-';
// minusDiv.textContent = '-';
gutterDiv.appendChild(minusDiv);
return gutterDiv;

View file

@ -8,6 +8,7 @@ import { IInlineDiffService } from '../../../editor/browser/services/inlineDiffS
import { ICodeEditor } from '../../../editor/browser/editorBrowser.js';
import { IRange } from '../../../editor/common/core/range.js';
import { extHostNamedCustomer, IExtHostContext } from '../../services/extensions/common/extHostCustomers.js';
// import { IHistoryService } from '../../services/history/common/history.js';
@extHostNamedCustomer(MainContext.MainThreadInlineDiff)
@ -20,14 +21,18 @@ export class MainThreadInlineDiff extends Disposable implements MainThreadInline
context: IExtHostContext,
@IInlineDiffService private readonly _inlineDiff: IInlineDiffService,
@ICodeEditorService private readonly _editorService: ICodeEditorService,
// @IHistoryService private readonly _historyService: IHistoryService,
) {
super();
// this._proxy = context.getProxy(ExtHostContext.ExtHostEditorInsets);
// this._wcHistoryService.addEntry()
}
// this._proxy = context.getProxy(ExtHostContext.ExtHostEditorInsets);
// dispose(): void {
// this._disposables.dispose();
// }
initStream() {
}
$addDiff(editorId: string, originalText: string, range: IRange): void {
@ -50,33 +55,6 @@ export class MainThreadInlineDiff extends Disposable implements MainThreadInline
this._inlineDiff.addDiff(editor, originalText, range)
// return editor
// const disposables = new DisposableStore();
// const remove = () => {
// disposables.dispose();
// this._proxy.$onDidDispose(handle);
// this._insets.delete(handle);
// };
// disposables.add(editor.onDidChangeModel(remove));
// disposables.add(editor.onDidDispose(remove));
}
// $disposeEditorInset(handle: number): void {
// const inset = this.getInset(handle);
// this._insets.delete(handle);
// inset.dispose();
// }
// private getInset(handle: number): EditorWebviewZone {
// const inset = this._insets.get(handle);
// if (!inset) {
// throw new Error('Unknown inset');
// }
// return inset;
// }
}