Skip to content

Align gutter width with old compiler #517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/diagnosticwriter/diagnosticwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func writeCodeSnippet(writer io.Writer, sourceFile *ast.SourceFile, start int, l
lastLineOfFile, _ := scanner.GetLineAndCharacterOfPosition(sourceFile, len(sourceFile.Text))

hasMoreThanFiveLines := lastLine-firstLine >= 4
gutterWidth := len(strconv.Itoa(lastLineOfFile + 1 + len("")))
gutterWidth := len(strconv.Itoa(lastLine + 1))
Comment on lines 92 to +93
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference, the original code is:

    const hasMoreThanFiveLines = (lastLine - firstLine) >= 4;
    let gutterWidth = (lastLine + 1 + "").length;
    if (hasMoreThanFiveLines) {
        gutterWidth = Math.max(ellipsis.length, gutterWidth);
    }

So your fix is definitely correct; the + "" was a conversion.

if hasMoreThanFiveLines {
gutterWidth = max(len(ellipsis), gutterWidth)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
   ~~~~~

deeplyNestedAssignabilityIssue.ts:2:5 - 'a' is declared here.
 2 a: number;
   ~
2 a: number;
   ~

deeplyNestedAssignabilityIssue.ts:9:17 - The expected type comes from property 'thing' which is declared here on type '{ thing: A; }'
 9 thing: A;
   ~~~~~
9 thing: A;
   ~~~~~

deeplyNestedAssignabilityIssue.ts:25:17 - error TS2741: Property 'a' is missing in type '{}' but required in type 'A'.

25 another: {}
   ~~~~~~~

deeplyNestedAssignabilityIssue.ts:2:5 - 'a' is declared here.
 2 a: number;
   ~
2 a: number;
   ~

deeplyNestedAssignabilityIssue.ts:12:17 - The expected type comes from property 'another' which is declared here on type '{ another: A; }'
12 another: A;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,28 @@
   ~~~~~

- deeplyNestedAssignabilityIssue.ts:2:5
- 2 a: number;
-    ~
+ deeplyNestedAssignabilityIssue.ts:2:5 - 'a' is declared here.
2 a: number;
   ~
- 'a' is declared here.
- deeplyNestedAssignabilityIssue.ts:9:17
- 9 thing: A;
-    ~~~~~
- The expected type comes from property 'thing' which is declared here on type '{ thing: A; }'
+ deeplyNestedAssignabilityIssue.ts:2:5 - 'a' is declared here.
+  2 a: number;
+    ~
+
+ deeplyNestedAssignabilityIssue.ts:9:17 - The expected type comes from property 'thing' which is declared here on type '{ thing: A; }'
+  9 thing: A;
+    ~~~~~
9 thing: A;
   ~~~~~
- The expected type comes from property 'thing' which is declared here on type '{ thing: A; }'
+
deeplyNestedAssignabilityIssue.ts:25:17 - error TS2741: Property 'a' is missing in type '{}' but required in type 'A'.

25 another: {}
   ~~~~~~~

- deeplyNestedAssignabilityIssue.ts:2:5
- 2 a: number;
-    ~
+ deeplyNestedAssignabilityIssue.ts:2:5 - 'a' is declared here.
2 a: number;
   ~
- 'a' is declared here.
- deeplyNestedAssignabilityIssue.ts:12:17
+ deeplyNestedAssignabilityIssue.ts:2:5 - 'a' is declared here.
+  2 a: number;
+    ~
+
+ deeplyNestedAssignabilityIssue.ts:12:17 - The expected type comes from property 'another' which is declared here on type '{ another: A; }'
12 another: A;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,157 +4,157 @@
   ~

file2.ts:1:7 - 'A' was also declared here.
 1 class A { }
   ~
1 class A { }
   ~

file1.ts:2:7 - error TS2300: Duplicate identifier 'B'.

2 class B { }
   ~

file2.ts:2:7 - 'B' was also declared here.
 2 class B { }
   ~
2 class B { }
   ~

file1.ts:3:7 - error TS2300: Duplicate identifier 'C'.

3 class C { }
   ~

file2.ts:3:7 - 'C' was also declared here.
 3 class C { }
   ~
3 class C { }
   ~

file1.ts:4:7 - error TS2300: Duplicate identifier 'D'.

4 class D { }
   ~

file2.ts:4:7 - 'D' was also declared here.
 4 class D { }
   ~
4 class D { }
   ~

file1.ts:5:7 - error TS2300: Duplicate identifier 'E'.

5 class E { }
   ~

file2.ts:5:7 - 'E' was also declared here.
 5 class E { }
   ~
5 class E { }
   ~

file1.ts:6:7 - error TS2300: Duplicate identifier 'F'.

6 class F { }
   ~

file2.ts:6:7 - 'F' was also declared here.
 6 class F { }
   ~
6 class F { }
   ~

file1.ts:7:7 - error TS2300: Duplicate identifier 'G'.

7 class G { }
   ~

file2.ts:7:7 - 'G' was also declared here.
 7 class G { }
   ~
7 class G { }
   ~

file1.ts:8:7 - error TS2300: Duplicate identifier 'H'.

8 class H { }
   ~

file2.ts:8:7 - 'H' was also declared here.
 8 class H { }
   ~
8 class H { }
   ~

file1.ts:9:7 - error TS2300: Duplicate identifier 'I'.

9 class I { }
   ~

file2.ts:9:7 - 'I' was also declared here.
 9 class I { }
   ~
9 class I { }
   ~

file2.ts:1:7 - error TS2300: Duplicate identifier 'A'.

 1 class A { }
   ~
1 class A { }
   ~

file1.ts:1:7 - 'A' was also declared here.
1 class A { }
   ~

file2.ts:2:7 - error TS2300: Duplicate identifier 'B'.

 2 class B { }
   ~
2 class B { }
   ~

file1.ts:2:7 - 'B' was also declared here.
2 class B { }
   ~

file2.ts:3:7 - error TS2300: Duplicate identifier 'C'.

 3 class C { }
   ~
3 class C { }
   ~

file1.ts:3:7 - 'C' was also declared here.
3 class C { }
   ~

file2.ts:4:7 - error TS2300: Duplicate identifier 'D'.

 4 class D { }
   ~
4 class D { }
   ~

file1.ts:4:7 - 'D' was also declared here.
4 class D { }
   ~

file2.ts:5:7 - error TS2300: Duplicate identifier 'E'.

 5 class E { }
   ~
5 class E { }
   ~

file1.ts:5:7 - 'E' was also declared here.
5 class E { }
   ~

file2.ts:6:7 - error TS2300: Duplicate identifier 'F'.

 6 class F { }
   ~
6 class F { }
   ~

file1.ts:6:7 - 'F' was also declared here.
6 class F { }
   ~

file2.ts:7:7 - error TS2300: Duplicate identifier 'G'.

 7 class G { }
   ~
7 class G { }
   ~

file1.ts:7:7 - 'G' was also declared here.
7 class G { }
   ~

file2.ts:8:7 - error TS2300: Duplicate identifier 'H'.

 8 class H { }
   ~
8 class H { }
   ~

file1.ts:8:7 - 'H' was also declared here.
8 class H { }
   ~

file2.ts:9:7 - error TS2300: Duplicate identifier 'I'.

 9 class I { }
   ~
9 class I { }
   ~

file1.ts:9:7 - 'I' was also declared here.
9 class I { }
Expand Down
Loading