@@ -47,8 +47,8 @@ var DEFAULT_SETTINGS = {
4747
4848## Which gutter lint icons are shown in.
4949## By default, gutter 0 is for breakpoints and 1 is for things like overrides.
50- # FIXME: see other FIXME comment about gutter icons
51- # const LINT_ICON_GUTTER := 2
50+ const GUTTER_LINT_ICON_INDEX = 2
51+ const GUTTER_LINT_ICONS_NAME = "gdscript_formatter_lint_icons"
5252
5353var connection_list : Array [Resource ] = []
5454var installer : FormatterInstaller = null
@@ -600,26 +600,30 @@ func parse_lint_issue(line: String) -> Dictionary:
600600func apply_lint_highlights (code_edit : CodeEdit , issues : Array ) -> void :
601601 clear_lint_highlights (code_edit )
602602
603+ # Add and set up gutter for lint icons if not already present.
604+ # We check by name to avoid conflicts with gutters added by other addons.
605+ # Once added, the gutter is never removed so the layout doesn't shift on clear.
606+ var has_lint_gutter := false
607+ for i : int in code_edit .get_gutter_count ():
608+ if code_edit .get_gutter_name (i ) == GUTTER_LINT_ICONS_NAME :
609+ has_lint_gutter = true
610+ break
611+ if not has_lint_gutter :
612+ code_edit .add_gutter (GUTTER_LINT_ICON_INDEX )
613+ code_edit .set_gutter_name (GUTTER_LINT_ICON_INDEX , GUTTER_LINT_ICONS_NAME )
614+ code_edit .set_gutter_type (GUTTER_LINT_ICON_INDEX , CodeEdit .GutterType .GUTTER_TYPE_ICON )
615+ const EDITOR_ICON_DEFAULT_WIDTH = 16.0
616+ code_edit .set_gutter_width (GUTTER_LINT_ICON_INDEX , EDITOR_ICON_DEFAULT_WIDTH * EditorInterface .get_editor_scale ())
617+
603618 for issue in issues :
604619 var line_number : int = issue .line
605620 var severity : String = issue .severity
606621
607- # Set line background color based on severity
608- var color : Color
609- if severity == "error" :
610- color = Color (1 , 0 , 0 , 0.1 )
611- else : # warning
612- color = Color (1 , 1 , 0 , 0.1 )
613-
622+ var color := Color (1 , 0 , 0 , 0.1 ) if severity == "error" else Color (1 , 1 , 0 , 0.1 )
614623 code_edit .set_line_background_color (line_number , color )
615-
616- # FIXME: This currently removes line numbers as Godot's script editor uses all its gutters,
617- # I commented out the code in case someone wants to solve it, otherwise this should be removed.
618- #
619- # var icon_name = "StatusError" if severity == "error" else "StatusWarning"
620- # var icon = EditorInterface.get_editor_theme().get_icon(icon_name, "EditorIcons")
621- # code_edit.set_gutter_type(LINT_ICON_GUTTER, CodeEdit.GutterType.GUTTER_TYPE_ICON)
622- # code_edit.set_line_gutter_icon(line_number, LINT_ICON_GUTTER, icon)
624+ var icon_name := "StatusError" if severity == "error" else "StatusWarning"
625+ var icon := EditorInterface .get_editor_theme ().get_icon (icon_name , "EditorIcons" )
626+ code_edit .set_line_gutter_icon (line_number , GUTTER_LINT_ICON_INDEX , icon )
623627
624628
625629## Prints a detailed summary of lint issues to the output
@@ -643,12 +647,19 @@ func print_lint_summary(issues: Array, script_path: String) -> void:
643647 print_rich ("[b]=== End Linting Results ===[/b]\n " )
644648
645649
646- ## Clears all lint highlighting from the code editor
650+ ## Clears all lint highlighting from the code editor.
651+ ## The lint gutter is intentionally kept so the layout does not shift.
647652func clear_lint_highlights (code_edit : CodeEdit ) -> void :
653+ var lint_gutter_index := - 1
654+ for i : int in code_edit .get_gutter_count ():
655+ if code_edit .get_gutter_name (i ) == GUTTER_LINT_ICONS_NAME :
656+ lint_gutter_index = i
657+ break
658+
648659 for line in range (code_edit .get_line_count ()):
649660 code_edit .set_line_background_color (line , Color (0 , 0 , 0 , 0 ))
650- # FIXME: See other FIXME comment about gutter icons
651- # code_edit.set_line_gutter_icon(line, LINT_ICON_GUTTER , null)
661+ if lint_gutter_index != - 1 :
662+ code_edit .set_line_gutter_icon (line , lint_gutter_index , null )
652663
653664
654665## Data structure to hold code editor state information
0 commit comments