Skip to content

Commit 4af8285

Browse files
committed
Renderers refactoring
1 parent 505232c commit 4af8285

9 files changed

Lines changed: 1758 additions & 1568 deletions

File tree

anycode-base/src/diff.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export type DiffInfo = {
2121
hunkId: number;
2222
};
2323

24-
export function computeGitChangesDetailed(
24+
export function computeGitChanges(
2525
original: string, current: string
2626
): Map<number, DiffInfo> {
2727
const changes = new Map<number, DiffInfo>();

anycode-base/src/editor.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
2-
3-
import { Code, Edit, Change, Position, Operation } from "./code";
1+
import { Code, Change, Position, Operation } from "./code";
42
import { vesper } from './theme';
5-
import { Renderer } from './renderer';
3+
import { Renderer } from './renderer/Renderer';
64
import { getPosFromMouse } from './mouse';
75
import { Selection } from "./selection";
86
import { Completion, CompletionRequest, DefinitionRequest, DefinitionResponse } from "./lsp";
@@ -18,7 +16,7 @@ import {
1816

1917
import './styles.css';
2018
import { Search } from "./search";
21-
import { computeGitChangesDetailed as computeGitChanges, ChangeType, DiffInfo } from "./diff";
19+
import { computeGitChanges, DiffInfo } from "./diff";
2220

2321
export interface EditorSettings {
2422
lineHeight: number;
@@ -32,7 +30,7 @@ export interface EditorState {
3230
runLines: number[];
3331
errorLines: Map<number, string>;
3432
settings: EditorSettings;
35-
diffResult?: Map<number, DiffInfo>;
33+
diffs?: Map<number, DiffInfo>;
3634
}
3735

3836
export class AnycodeEditor {
@@ -44,8 +42,6 @@ export class AnycodeEditor {
4442
private buttonsColumn!: HTMLDivElement;
4543
private gutter!: HTMLDivElement;
4644
private codeContent!: HTMLDivElement;
47-
private isFocused: boolean;
48-
private maxLineWidth = 0;
4945

5046
private isMouseSelecting: boolean = false;
5147
private selection: Selection | null = null;
@@ -101,7 +97,6 @@ export class AnycodeEditor {
10197
addCssToDocument(css, 'anyeditor-theme');
10298
this.createDomElements();
10399
this.renderer = new Renderer(this.container, this.buttonsColumn, this.gutter, this.codeContent);
104-
this.isFocused = true;
105100
}
106101

107102
private createDomElements() {
@@ -304,7 +299,7 @@ export class AnycodeEditor {
304299
lineHeight: this.settings.lineHeight,
305300
buffer: this.settings.buffer,
306301
},
307-
diffResult: this.diffs,
302+
diffs: this.diffs,
308303
};
309304
}
310305

@@ -383,7 +378,6 @@ export class AnycodeEditor {
383378
// console.log('Editor lost focus');
384379
this.isMouseSelecting = false;
385380
this.isWordSelection = false;
386-
this.isFocused = false;
387381

388382
if (this.autoScrollTimer) {
389383
cancelAnimationFrame(this.autoScrollTimer);
@@ -393,7 +387,6 @@ export class AnycodeEditor {
393387

394388
private handleFocus(e: FocusEvent) {
395389
// console.log('Editor focus');
396-
this.isFocused = true;
397390
this.search.setNeedsFocus(false);
398391
}
399392

@@ -1109,7 +1102,7 @@ export class AnycodeEditor {
11091102
this.renderer.clearAllDiffs();
11101103
}
11111104

1112-
this.renderer.verifyDiffRendering(this.diffs);
1105+
this.renderer.verifyDiffs(this.diffs);
11131106
}
11141107

11151108
}

0 commit comments

Comments
 (0)