wyreframe 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/parser/Fixer/Fixer.mjs +32 -27
- package/src/parser/Fixer/Fixer.res +51 -30
package/package.json
CHANGED
|
@@ -52,7 +52,8 @@ function fixMisalignedPipe(text, error) {
|
|
|
52
52
|
let expectedCol = match.expectedCol;
|
|
53
53
|
let position = match.position;
|
|
54
54
|
let lines = text.split("\n");
|
|
55
|
-
let
|
|
55
|
+
let rowIndex = position.row - 1 | 0;
|
|
56
|
+
let line = lines[rowIndex];
|
|
56
57
|
if (line === undefined) {
|
|
57
58
|
return;
|
|
58
59
|
}
|
|
@@ -68,14 +69,14 @@ function fixMisalignedPipe(text, error) {
|
|
|
68
69
|
if (newLine === line) {
|
|
69
70
|
return;
|
|
70
71
|
}
|
|
71
|
-
let newLines = replaceLine(lines,
|
|
72
|
+
let newLines = replaceLine(lines, rowIndex, newLine);
|
|
72
73
|
let fixedText = newLines.join("\n");
|
|
73
74
|
return [
|
|
74
75
|
fixedText,
|
|
75
76
|
{
|
|
76
77
|
original: error,
|
|
77
|
-
description: `Aligned pipe at line ` +
|
|
78
|
-
line: position.row
|
|
78
|
+
description: `Aligned pipe at line ` + position.row.toString() + ` to column ` + (expectedCol + 1 | 0).toString(),
|
|
79
|
+
line: position.row,
|
|
79
80
|
column: expectedCol + 1 | 0
|
|
80
81
|
}
|
|
81
82
|
];
|
|
@@ -90,7 +91,8 @@ function fixMisalignedClosingBorder(text, error) {
|
|
|
90
91
|
let expectedCol = match.expectedCol;
|
|
91
92
|
let position = match.position;
|
|
92
93
|
let lines = text.split("\n");
|
|
93
|
-
let
|
|
94
|
+
let rowIndex = position.row - 1 | 0;
|
|
95
|
+
let line = lines[rowIndex];
|
|
94
96
|
if (line === undefined) {
|
|
95
97
|
return;
|
|
96
98
|
}
|
|
@@ -106,14 +108,14 @@ function fixMisalignedClosingBorder(text, error) {
|
|
|
106
108
|
if (newLine === line) {
|
|
107
109
|
return;
|
|
108
110
|
}
|
|
109
|
-
let newLines = replaceLine(lines,
|
|
111
|
+
let newLines = replaceLine(lines, rowIndex, newLine);
|
|
110
112
|
let fixedText = newLines.join("\n");
|
|
111
113
|
return [
|
|
112
114
|
fixedText,
|
|
113
115
|
{
|
|
114
116
|
original: error,
|
|
115
|
-
description: `Aligned closing border at line ` +
|
|
116
|
-
line: position.row
|
|
117
|
+
description: `Aligned closing border at line ` + position.row.toString() + ` to column ` + (expectedCol + 1 | 0).toString(),
|
|
118
|
+
line: position.row,
|
|
117
119
|
column: expectedCol + 1 | 0
|
|
118
120
|
}
|
|
119
121
|
];
|
|
@@ -130,7 +132,8 @@ function fixUnusualSpacing(text, error) {
|
|
|
130
132
|
}
|
|
131
133
|
let position = match.position;
|
|
132
134
|
let lines = text.split("\n");
|
|
133
|
-
let
|
|
135
|
+
let rowIndex = position.row - 1 | 0;
|
|
136
|
+
let line = lines[rowIndex];
|
|
134
137
|
if (line === undefined) {
|
|
135
138
|
return;
|
|
136
139
|
}
|
|
@@ -138,14 +141,14 @@ function fixUnusualSpacing(text, error) {
|
|
|
138
141
|
if (newLine === line) {
|
|
139
142
|
return;
|
|
140
143
|
}
|
|
141
|
-
let newLines = replaceLine(lines,
|
|
144
|
+
let newLines = replaceLine(lines, rowIndex, newLine);
|
|
142
145
|
let fixedText = newLines.join("\n");
|
|
143
146
|
return [
|
|
144
147
|
fixedText,
|
|
145
148
|
{
|
|
146
149
|
original: error,
|
|
147
|
-
description: `Replaced tabs with spaces at line ` +
|
|
148
|
-
line: position.row
|
|
150
|
+
description: `Replaced tabs with spaces at line ` + position.row.toString(),
|
|
151
|
+
line: position.row,
|
|
149
152
|
column: position.col + 1 | 0
|
|
150
153
|
}
|
|
151
154
|
];
|
|
@@ -158,7 +161,8 @@ function fixUnclosedBracket(text, error) {
|
|
|
158
161
|
}
|
|
159
162
|
let opening = match.opening;
|
|
160
163
|
let lines = text.split("\n");
|
|
161
|
-
let
|
|
164
|
+
let rowIndex = opening.row - 1 | 0;
|
|
165
|
+
let line = lines[rowIndex];
|
|
162
166
|
if (line === undefined) {
|
|
163
167
|
return;
|
|
164
168
|
}
|
|
@@ -167,14 +171,14 @@ function fixUnclosedBracket(text, error) {
|
|
|
167
171
|
return;
|
|
168
172
|
}
|
|
169
173
|
let newLine = trimmedLine + " ]";
|
|
170
|
-
let newLines = replaceLine(lines,
|
|
174
|
+
let newLines = replaceLine(lines, rowIndex, newLine);
|
|
171
175
|
let fixedText = newLines.join("\n");
|
|
172
176
|
return [
|
|
173
177
|
fixedText,
|
|
174
178
|
{
|
|
175
179
|
original: error,
|
|
176
|
-
description: `Added closing bracket at line ` +
|
|
177
|
-
line: opening.row
|
|
180
|
+
description: `Added closing bracket at line ` + opening.row.toString(),
|
|
181
|
+
line: opening.row,
|
|
178
182
|
column: trimmedLine.length + 2 | 0
|
|
179
183
|
}
|
|
180
184
|
];
|
|
@@ -190,6 +194,7 @@ function fixMismatchedWidth(text, error) {
|
|
|
190
194
|
let topLeft = match.topLeft;
|
|
191
195
|
let lines = text.split("\n");
|
|
192
196
|
let diff = topWidth - bottomWidth | 0;
|
|
197
|
+
let topLeftRowIndex = topLeft.row - 1 | 0;
|
|
193
198
|
if (diff === 0) {
|
|
194
199
|
return;
|
|
195
200
|
}
|
|
@@ -206,7 +211,7 @@ function fixMismatchedWidth(text, error) {
|
|
|
206
211
|
let col = topLeft.col;
|
|
207
212
|
if (col < line.length) {
|
|
208
213
|
let char = line.charAt(col);
|
|
209
|
-
if (char === "+" && row >
|
|
214
|
+
if (char === "+" && row > topLeftRowIndex) {
|
|
210
215
|
return row;
|
|
211
216
|
}
|
|
212
217
|
_row = row + 1 | 0;
|
|
@@ -216,11 +221,11 @@ function fixMismatchedWidth(text, error) {
|
|
|
216
221
|
continue;
|
|
217
222
|
};
|
|
218
223
|
};
|
|
219
|
-
let
|
|
220
|
-
if (
|
|
224
|
+
let bottomRowIndex = findBottomRow(topLeftRowIndex + 1 | 0);
|
|
225
|
+
if (bottomRowIndex === undefined) {
|
|
221
226
|
return;
|
|
222
227
|
}
|
|
223
|
-
let bottomLine = lines[
|
|
228
|
+
let bottomLine = lines[bottomRowIndex];
|
|
224
229
|
if (bottomLine === undefined) {
|
|
225
230
|
return;
|
|
226
231
|
}
|
|
@@ -233,19 +238,19 @@ function fixMismatchedWidth(text, error) {
|
|
|
233
238
|
let after = bottomLine.slice(closingPlusCol);
|
|
234
239
|
let dashes = "-".repeat(diff);
|
|
235
240
|
let newLine = before + dashes + after;
|
|
236
|
-
let newLines = replaceLine(lines,
|
|
241
|
+
let newLines = replaceLine(lines, bottomRowIndex, newLine);
|
|
237
242
|
let fixedText = newLines.join("\n");
|
|
238
243
|
return [
|
|
239
244
|
fixedText,
|
|
240
245
|
{
|
|
241
246
|
original: error,
|
|
242
|
-
description: `Extended bottom border at line ` + (
|
|
243
|
-
line:
|
|
247
|
+
description: `Extended bottom border at line ` + (bottomRowIndex + 1 | 0).toString() + ` by ` + diff.toString() + ` characters`,
|
|
248
|
+
line: bottomRowIndex + 1 | 0,
|
|
244
249
|
column: closingPlusCol + 1 | 0
|
|
245
250
|
}
|
|
246
251
|
];
|
|
247
252
|
}
|
|
248
|
-
let topLine = lines[
|
|
253
|
+
let topLine = lines[topLeftRowIndex];
|
|
249
254
|
if (topLine === undefined) {
|
|
250
255
|
return;
|
|
251
256
|
}
|
|
@@ -257,14 +262,14 @@ function fixMismatchedWidth(text, error) {
|
|
|
257
262
|
let after$1 = topLine.slice(closingPlusCol$1);
|
|
258
263
|
let dashes$1 = "-".repeat(Math.abs(diff));
|
|
259
264
|
let newLine$1 = before$1 + dashes$1 + after$1;
|
|
260
|
-
let newLines$1 = replaceLine(lines,
|
|
265
|
+
let newLines$1 = replaceLine(lines, topLeftRowIndex, newLine$1);
|
|
261
266
|
let fixedText$1 = newLines$1.join("\n");
|
|
262
267
|
return [
|
|
263
268
|
fixedText$1,
|
|
264
269
|
{
|
|
265
270
|
original: error,
|
|
266
|
-
description: `Extended top border at line ` +
|
|
267
|
-
line: topLeft.row
|
|
271
|
+
description: `Extended top border at line ` + topLeft.row.toString() + ` by ` + Math.abs(diff).toString() + ` characters`,
|
|
272
|
+
line: topLeft.row,
|
|
268
273
|
column: closingPlusCol$1 + 1 | 0
|
|
269
274
|
}
|
|
270
275
|
];
|
|
@@ -77,13 +77,17 @@ let replaceCharAt = (str: string, col: int, char: string): string => {
|
|
|
77
77
|
*
|
|
78
78
|
* Before: | content | (pipe at wrong column)
|
|
79
79
|
* After: | content | (pipe at correct column)
|
|
80
|
+
*
|
|
81
|
+
* Note: position.row is 1-indexed (from error messages), convert to 0-indexed for array access
|
|
80
82
|
*/
|
|
81
83
|
let fixMisalignedPipe = (text: string, error: ErrorTypes.t): option<(string, fixedIssue)> => {
|
|
82
84
|
switch error.code {
|
|
83
85
|
| MisalignedPipe({position, expectedCol, actualCol}) => {
|
|
84
86
|
let lines = splitLines(text)
|
|
87
|
+
// Convert 1-indexed row to 0-indexed for array access
|
|
88
|
+
let rowIndex = position.row - 1
|
|
85
89
|
|
|
86
|
-
switch getLine(lines,
|
|
90
|
+
switch getLine(lines, rowIndex) {
|
|
87
91
|
| None => None
|
|
88
92
|
| Some(line) => {
|
|
89
93
|
// Calculate how many spaces to add or remove
|
|
@@ -94,7 +98,7 @@ let fixMisalignedPipe = (text: string, error: ErrorTypes.t): option<(string, fix
|
|
|
94
98
|
insertAt(line, actualCol, String.repeat(" ", diff))
|
|
95
99
|
} else {
|
|
96
100
|
// Need to remove spaces before the pipe
|
|
97
|
-
let removeCount =
|
|
101
|
+
let removeCount = Math.Int.abs(diff)
|
|
98
102
|
// Make sure we're removing spaces, not content
|
|
99
103
|
let beforePipe = line->String.slice(~start=actualCol + diff, ~end=actualCol)
|
|
100
104
|
if beforePipe->String.trim === "" {
|
|
@@ -105,15 +109,15 @@ let fixMisalignedPipe = (text: string, error: ErrorTypes.t): option<(string, fix
|
|
|
105
109
|
}
|
|
106
110
|
|
|
107
111
|
if newLine !== line {
|
|
108
|
-
let newLines = replaceLine(lines,
|
|
112
|
+
let newLines = replaceLine(lines, rowIndex, newLine)
|
|
109
113
|
let fixedText = joinLines(newLines)
|
|
110
114
|
|
|
111
115
|
Some((
|
|
112
116
|
fixedText,
|
|
113
117
|
{
|
|
114
118
|
original: error,
|
|
115
|
-
description: `Aligned pipe at line ${Int.toString(position.row
|
|
116
|
-
line: position.row
|
|
119
|
+
description: `Aligned pipe at line ${Int.toString(position.row)} to column ${Int.toString(expectedCol + 1)}`,
|
|
120
|
+
line: position.row,
|
|
117
121
|
column: expectedCol + 1,
|
|
118
122
|
},
|
|
119
123
|
))
|
|
@@ -129,13 +133,17 @@ let fixMisalignedPipe = (text: string, error: ErrorTypes.t): option<(string, fix
|
|
|
129
133
|
|
|
130
134
|
/**
|
|
131
135
|
* Fix MisalignedClosingBorder - adjust closing '|' position
|
|
136
|
+
*
|
|
137
|
+
* Note: position.row is 1-indexed (from error messages), convert to 0-indexed for array access
|
|
132
138
|
*/
|
|
133
139
|
let fixMisalignedClosingBorder = (text: string, error: ErrorTypes.t): option<(string, fixedIssue)> => {
|
|
134
140
|
switch error.code {
|
|
135
141
|
| MisalignedClosingBorder({position, expectedCol, actualCol}) => {
|
|
136
142
|
let lines = splitLines(text)
|
|
143
|
+
// Convert 1-indexed row to 0-indexed for array access
|
|
144
|
+
let rowIndex = position.row - 1
|
|
137
145
|
|
|
138
|
-
switch getLine(lines,
|
|
146
|
+
switch getLine(lines, rowIndex) {
|
|
139
147
|
| None => None
|
|
140
148
|
| Some(line) => {
|
|
141
149
|
let diff = expectedCol - actualCol
|
|
@@ -145,7 +153,7 @@ let fixMisalignedClosingBorder = (text: string, error: ErrorTypes.t): option<(st
|
|
|
145
153
|
insertAt(line, actualCol, String.repeat(" ", diff))
|
|
146
154
|
} else {
|
|
147
155
|
// Need to remove spaces before the closing pipe
|
|
148
|
-
let removeCount =
|
|
156
|
+
let removeCount = Math.Int.abs(diff)
|
|
149
157
|
let beforePipe = line->String.slice(~start=actualCol + diff, ~end=actualCol)
|
|
150
158
|
if beforePipe->String.trim === "" {
|
|
151
159
|
removeAt(line, actualCol + diff, removeCount)
|
|
@@ -155,15 +163,15 @@ let fixMisalignedClosingBorder = (text: string, error: ErrorTypes.t): option<(st
|
|
|
155
163
|
}
|
|
156
164
|
|
|
157
165
|
if newLine !== line {
|
|
158
|
-
let newLines = replaceLine(lines,
|
|
166
|
+
let newLines = replaceLine(lines, rowIndex, newLine)
|
|
159
167
|
let fixedText = joinLines(newLines)
|
|
160
168
|
|
|
161
169
|
Some((
|
|
162
170
|
fixedText,
|
|
163
171
|
{
|
|
164
172
|
original: error,
|
|
165
|
-
description: `Aligned closing border at line ${Int.toString(position.row
|
|
166
|
-
line: position.row
|
|
173
|
+
description: `Aligned closing border at line ${Int.toString(position.row)} to column ${Int.toString(expectedCol + 1)}`,
|
|
174
|
+
line: position.row,
|
|
167
175
|
column: expectedCol + 1,
|
|
168
176
|
},
|
|
169
177
|
))
|
|
@@ -179,6 +187,8 @@ let fixMisalignedClosingBorder = (text: string, error: ErrorTypes.t): option<(st
|
|
|
179
187
|
|
|
180
188
|
/**
|
|
181
189
|
* Fix UnusualSpacing - replace tabs with spaces
|
|
190
|
+
*
|
|
191
|
+
* Note: position.row is 1-indexed (from error messages), convert to 0-indexed for array access
|
|
182
192
|
*/
|
|
183
193
|
let fixUnusualSpacing = (text: string, error: ErrorTypes.t): option<(string, fixedIssue)> => {
|
|
184
194
|
switch error.code {
|
|
@@ -186,23 +196,25 @@ let fixUnusualSpacing = (text: string, error: ErrorTypes.t): option<(string, fix
|
|
|
186
196
|
// Check if the issue is about tabs
|
|
187
197
|
if issue->String.includes("tab") || issue->String.includes("Tab") {
|
|
188
198
|
let lines = splitLines(text)
|
|
199
|
+
// Convert 1-indexed row to 0-indexed for array access
|
|
200
|
+
let rowIndex = position.row - 1
|
|
189
201
|
|
|
190
|
-
switch getLine(lines,
|
|
202
|
+
switch getLine(lines, rowIndex) {
|
|
191
203
|
| None => None
|
|
192
204
|
| Some(line) => {
|
|
193
205
|
// Replace tabs with 2 spaces (common convention)
|
|
194
206
|
let newLine = line->String.replaceAll("\t", " ")
|
|
195
207
|
|
|
196
208
|
if newLine !== line {
|
|
197
|
-
let newLines = replaceLine(lines,
|
|
209
|
+
let newLines = replaceLine(lines, rowIndex, newLine)
|
|
198
210
|
let fixedText = joinLines(newLines)
|
|
199
211
|
|
|
200
212
|
Some((
|
|
201
213
|
fixedText,
|
|
202
214
|
{
|
|
203
215
|
original: error,
|
|
204
|
-
description: `Replaced tabs with spaces at line ${Int.toString(position.row
|
|
205
|
-
line: position.row
|
|
216
|
+
description: `Replaced tabs with spaces at line ${Int.toString(position.row)}`,
|
|
217
|
+
line: position.row,
|
|
206
218
|
column: position.col + 1,
|
|
207
219
|
},
|
|
208
220
|
))
|
|
@@ -221,13 +233,17 @@ let fixUnusualSpacing = (text: string, error: ErrorTypes.t): option<(string, fix
|
|
|
221
233
|
|
|
222
234
|
/**
|
|
223
235
|
* Fix UnclosedBracket - add closing ']' at end of line
|
|
236
|
+
*
|
|
237
|
+
* Note: opening.row is 1-indexed (from error messages), convert to 0-indexed for array access
|
|
224
238
|
*/
|
|
225
239
|
let fixUnclosedBracket = (text: string, error: ErrorTypes.t): option<(string, fixedIssue)> => {
|
|
226
240
|
switch error.code {
|
|
227
241
|
| UnclosedBracket({opening}) => {
|
|
228
242
|
let lines = splitLines(text)
|
|
243
|
+
// Convert 1-indexed row to 0-indexed for array access
|
|
244
|
+
let rowIndex = opening.row - 1
|
|
229
245
|
|
|
230
|
-
switch getLine(lines,
|
|
246
|
+
switch getLine(lines, rowIndex) {
|
|
231
247
|
| None => None
|
|
232
248
|
| Some(line) => {
|
|
233
249
|
// Find the content after '[' and close it
|
|
@@ -237,15 +253,15 @@ let fixUnclosedBracket = (text: string, error: ErrorTypes.t): option<(string, fi
|
|
|
237
253
|
if !(trimmedLine->String.endsWith("]")) {
|
|
238
254
|
// Add ' ]' with proper spacing
|
|
239
255
|
let newLine = trimmedLine ++ " ]"
|
|
240
|
-
let newLines = replaceLine(lines,
|
|
256
|
+
let newLines = replaceLine(lines, rowIndex, newLine)
|
|
241
257
|
let fixedText = joinLines(newLines)
|
|
242
258
|
|
|
243
259
|
Some((
|
|
244
260
|
fixedText,
|
|
245
261
|
{
|
|
246
262
|
original: error,
|
|
247
|
-
description: `Added closing bracket at line ${Int.toString(opening.row
|
|
248
|
-
line: opening.row
|
|
263
|
+
description: `Added closing bracket at line ${Int.toString(opening.row)}`,
|
|
264
|
+
line: opening.row,
|
|
249
265
|
column: String.length(trimmedLine) + 2,
|
|
250
266
|
},
|
|
251
267
|
))
|
|
@@ -261,18 +277,23 @@ let fixUnclosedBracket = (text: string, error: ErrorTypes.t): option<(string, fi
|
|
|
261
277
|
|
|
262
278
|
/**
|
|
263
279
|
* Fix MismatchedWidth - extend the shorter border to match the longer one
|
|
280
|
+
*
|
|
281
|
+
* Note: topLeft.row is 1-indexed (from error messages), convert to 0-indexed for array access
|
|
264
282
|
*/
|
|
265
283
|
let fixMismatchedWidth = (text: string, error: ErrorTypes.t): option<(string, fixedIssue)> => {
|
|
266
284
|
switch error.code {
|
|
267
285
|
| MismatchedWidth({topLeft, topWidth, bottomWidth}) => {
|
|
268
286
|
let lines = splitLines(text)
|
|
269
287
|
let diff = topWidth - bottomWidth
|
|
288
|
+
// Convert 1-indexed row to 0-indexed for array access
|
|
289
|
+
let topLeftRowIndex = topLeft.row - 1
|
|
270
290
|
|
|
271
291
|
if diff === 0 {
|
|
272
292
|
None
|
|
273
293
|
} else {
|
|
274
294
|
// Find the bottom border line
|
|
275
295
|
// We need to trace down from topLeft to find the bottom
|
|
296
|
+
// Note: row here is 0-indexed array index
|
|
276
297
|
let rec findBottomRow = (row: int): option<int> => {
|
|
277
298
|
if row >= Array.length(lines) {
|
|
278
299
|
None
|
|
@@ -284,7 +305,7 @@ let fixMismatchedWidth = (text: string, error: ErrorTypes.t): option<(string, fi
|
|
|
284
305
|
let col = topLeft.col
|
|
285
306
|
if col < String.length(line) {
|
|
286
307
|
let char = line->String.charAt(col)
|
|
287
|
-
if char === "+" && row >
|
|
308
|
+
if char === "+" && row > topLeftRowIndex {
|
|
288
309
|
Some(row)
|
|
289
310
|
} else {
|
|
290
311
|
findBottomRow(row + 1)
|
|
@@ -297,10 +318,10 @@ let fixMismatchedWidth = (text: string, error: ErrorTypes.t): option<(string, fi
|
|
|
297
318
|
}
|
|
298
319
|
}
|
|
299
320
|
|
|
300
|
-
switch findBottomRow(
|
|
321
|
+
switch findBottomRow(topLeftRowIndex + 1) {
|
|
301
322
|
| None => None
|
|
302
|
-
| Some(
|
|
303
|
-
switch getLine(lines,
|
|
323
|
+
| Some(bottomRowIndex) => {
|
|
324
|
+
switch getLine(lines, bottomRowIndex) {
|
|
304
325
|
| None => None
|
|
305
326
|
| Some(bottomLine) => {
|
|
306
327
|
if diff > 0 {
|
|
@@ -313,15 +334,15 @@ let fixMismatchedWidth = (text: string, error: ErrorTypes.t): option<(string, fi
|
|
|
313
334
|
let dashes = String.repeat("-", diff)
|
|
314
335
|
let newLine = before ++ dashes ++ after
|
|
315
336
|
|
|
316
|
-
let newLines = replaceLine(lines,
|
|
337
|
+
let newLines = replaceLine(lines, bottomRowIndex, newLine)
|
|
317
338
|
let fixedText = joinLines(newLines)
|
|
318
339
|
|
|
319
340
|
Some((
|
|
320
341
|
fixedText,
|
|
321
342
|
{
|
|
322
343
|
original: error,
|
|
323
|
-
description: `Extended bottom border at line ${Int.toString(
|
|
324
|
-
line:
|
|
344
|
+
description: `Extended bottom border at line ${Int.toString(bottomRowIndex + 1)} by ${Int.toString(diff)} characters`,
|
|
345
|
+
line: bottomRowIndex + 1,
|
|
325
346
|
column: closingPlusCol + 1,
|
|
326
347
|
},
|
|
327
348
|
))
|
|
@@ -332,25 +353,25 @@ let fixMismatchedWidth = (text: string, error: ErrorTypes.t): option<(string, fi
|
|
|
332
353
|
// Top is shorter, need to extend it
|
|
333
354
|
// This is trickier as it affects content alignment
|
|
334
355
|
// For now, we extend the top border
|
|
335
|
-
switch getLine(lines,
|
|
356
|
+
switch getLine(lines, topLeftRowIndex) {
|
|
336
357
|
| None => None
|
|
337
358
|
| Some(topLine) => {
|
|
338
359
|
let closingPlusCol = topLeft.col + topWidth - 1
|
|
339
360
|
if closingPlusCol >= 0 && closingPlusCol < String.length(topLine) {
|
|
340
361
|
let before = topLine->String.slice(~start=0, ~end=closingPlusCol)
|
|
341
362
|
let after = topLine->String.sliceToEnd(~start=closingPlusCol)
|
|
342
|
-
let dashes = String.repeat("-",
|
|
363
|
+
let dashes = String.repeat("-", Math.Int.abs(diff))
|
|
343
364
|
let newLine = before ++ dashes ++ after
|
|
344
365
|
|
|
345
|
-
let newLines = replaceLine(lines,
|
|
366
|
+
let newLines = replaceLine(lines, topLeftRowIndex, newLine)
|
|
346
367
|
let fixedText = joinLines(newLines)
|
|
347
368
|
|
|
348
369
|
Some((
|
|
349
370
|
fixedText,
|
|
350
371
|
{
|
|
351
372
|
original: error,
|
|
352
|
-
description: `Extended top border at line ${Int.toString(topLeft.row
|
|
353
|
-
line: topLeft.row
|
|
373
|
+
description: `Extended top border at line ${Int.toString(topLeft.row)} by ${Int.toString(Math.Int.abs(diff))} characters`,
|
|
374
|
+
line: topLeft.row,
|
|
354
375
|
column: closingPlusCol + 1,
|
|
355
376
|
},
|
|
356
377
|
))
|