Skip to content

Commit eb6f342

Browse files
committed
refactor: refactor the whole thing
1 parent db0d0e6 commit eb6f342

File tree

2 files changed

+1
-18
lines changed

2 files changed

+1
-18
lines changed

src/decoration-manager.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export default class DecorationManager {
2929
startLine?: number,
3030
endLine?: number
3131
) {
32-
console.log("fileName", this.fileName);
3332
/**
3433
* Active editor changed event
3534
*/
@@ -56,9 +55,8 @@ export default class DecorationManager {
5655

5756
setupDecorations(diffLine: number, startLine?: number, endLine?: number) {
5857
if (startLine && endLine) {
59-
console.log("diffLine", diffLine);
60-
6158
const lines = this.getLines(startLine, endLine);
59+
6260
if (diffLine < 0) {
6361
this.clearCurrentFileDecoration(lines);
6462
this.updateFileDecorationMap(diffLine, startLine);
@@ -79,7 +77,6 @@ export default class DecorationManager {
7977
}
8078

8179
setDecorations(sepecificLines?: number[]) {
82-
console.log("!!!!!!updating!!!!!");
8380
const text = this.activeEditor!.document.getText();
8481
const fullTokenKeys = Object.keys(this.fullToken);
8582
const lineDecorationMap: Map<number, vscode.TextEditorDecorationType[]> =
@@ -108,16 +105,13 @@ export default class DecorationManager {
108105
});
109106

110107
this.fileDecorationMap.set(this.fileName, lineDecorationMap);
111-
console.log(this.fileDecorationMap);
112108
}
113109

114110
clearCurrentFileDecoration(lines?: number[]) {
115111
const lineDecorationMapItem = this.fileDecorationMap.get(this.fileName);
116-
console.log("lineDecorationMapItem", lineDecorationMapItem);
117112
if (lineDecorationMapItem?.size) {
118113
if (lines) {
119114
lines.forEach((line) => {
120-
console.log("dispose line", line);
121115
if (lineDecorationMapItem.has(line)) {
122116
lineDecorationMapItem.get(line)?.forEach(this.dispose);
123117
lineDecorationMapItem.delete(line);
@@ -191,15 +185,12 @@ export default class DecorationManager {
191185
currentLine,
192186
lineValue ? lineValue.concat([decorationType]) : [decorationType]
193187
);
194-
// console.log("setDecorations", currentLine);
195188
this.activeEditor!.setDecorations(decorationType, valueDecorations);
196189
}
197190

198191
updateFileDecorationMap(diffLine: number, startLine: number) {
199192
const lineDecorationMapItem = this.fileDecorationMap.get(this.fileName);
200193
const newMap: Map<number, vscode.TextEditorDecorationType[]> = new Map();
201-
console.log("before: ", lineDecorationMapItem);
202-
console.log("startLine", startLine);
203194

204195
if (lineDecorationMapItem?.size) {
205196
lineDecorationMapItem.forEach((value, key) => {
@@ -214,7 +205,6 @@ export default class DecorationManager {
214205
});
215206
}
216207

217-
console.log("after: ", newMap);
218208
this.fileDecorationMap.set(this.fileName, newMap);
219209
}
220210
}

src/listener.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ export default function setupEventListener(
2323
}
2424

2525
if (activeEditor && event.document === activeEditor.document) {
26-
console.log("change", event.contentChanges[0]);
27-
2826
diffLine = activeEditor.document.lineCount - fileLineCount;
2927
fileLineCount = activeEditor.document.lineCount;
3028

@@ -33,7 +31,6 @@ export default function setupEventListener(
3331
event.contentChanges[0]
3432
);
3533

36-
console.log("editing", startLine, endLine);
3734
decorationManager.setActiveEditor(activeEditor);
3835
decorationManager.triggerUpdateDecorations(
3936
diffLine === 0,
@@ -77,10 +74,6 @@ export default function setupEventListener(
7774
);
7875
const isStartLineLastPos = startLineLastPos.isEqual(change.range.start);
7976

80-
console.log("original", startLine, endLine);
81-
console.log("isStartLineEmpty", isStartLineEmpty);
82-
console.log("isStartLineLastPos", isStartLineLastPos);
83-
8477
/**
8578
* paste multiple lines
8679
* there are some `\n` in `text`, but currentChange[0].range is always a single line

0 commit comments

Comments
 (0)