fortrangoingonforty/facsimile / f0cdbb9

Browse files

refactor: Reduce compiler warnings (118 -> 51)

- Fix uninitialized delimiter bug in syntax highlighter
- Comment out 6 unused functions
- Restore standard cursor goal column behavior
Authored by espadonne
SHA
f0cdbb95981f98539cb8fe224289d398fa83b7f4
Parents
77b404e
Tree
1b7efe8

5 changed files

StatusFile+-
M src/commands/command_handler_module.f90 6 5
M src/syntax/syntax_highlighter_module.f90 3 0
M src/terminal/renderer_module.f90 37 36
M src/ui/diagnostics_panel_module.f90 80 76
M src/ui/signature_tooltip_module.f90 90 88
src/commands/command_handler_module.f90modified
@@ -5279,11 +5279,12 @@ contains
52795279
         end if
52805280
     end subroutine toggle_fuss_mode
52815281
 
5282
-    ! Toggle diagnostics panel
5283
-    subroutine toggle_diagnostics_panel(editor)
5284
-        type(editor_state_t), intent(inout) :: editor
5285
-        call toggle_panel(editor%diagnostics_panel)
5286
-    end subroutine toggle_diagnostics_panel
5282
+    ! UNUSED: Toggle diagnostics panel
5283
+    ! Kept for potential future use
5284
+    ! subroutine toggle_diagnostics_panel(editor)
5285
+    !     type(editor_state_t), intent(inout) :: editor
5286
+    !     call toggle_panel(editor%diagnostics_panel)
5287
+    ! end subroutine toggle_diagnostics_panel
52875288
 
52885289
     ! Handle git commit with message prompt
52895290
     subroutine handle_git_commit(editor)
src/syntax/syntax_highlighter_module.f90modified
@@ -431,6 +431,9 @@ contains
431431
         line_len = len(line)
432432
         start_pos = pos
433433
 
434
+        ! Initialize delimiter (defensive programming - should always be set in loop below)
435
+        delimiter = '"'  ! Default fallback
436
+
434437
         ! Find which delimiter matches
435438
         do i = 1, size(highlighter%current_lang%string_delimiters)
436439
             delim_len = len_trim(highlighter%current_lang%string_delimiters(i))
src/terminal/renderer_module.f90modified
@@ -1791,42 +1791,43 @@ contains
17911791
         end do
17921792
     end subroutine render_tab_bar
17931793
 
1794
-    ! Get diagnostic marker and color for a line
1795
-    subroutine get_diagnostic_marker(diagnostics, marker, color)
1796
-        type(diagnostic_t), intent(in) :: diagnostics(:)
1797
-        character(len=3), intent(out) :: marker  ! UTF-8 characters can be up to 3 bytes
1798
-        character(len=:), allocatable, intent(out) :: color
1799
-        integer :: i, max_severity
1800
-
1801
-        marker = ' '
1802
-        color = ''
1803
-
1804
-        if (size(diagnostics) == 0) return
1805
-
1806
-        ! Find highest severity diagnostic
1807
-        max_severity = SEVERITY_HINT
1808
-        do i = 1, size(diagnostics)
1809
-            if (diagnostics(i)%severity < max_severity) then
1810
-                max_severity = diagnostics(i)%severity
1811
-            end if
1812
-        end do
1813
-
1814
-        ! Set marker and color based on severity
1815
-        select case(max_severity)
1816
-        case(SEVERITY_ERROR)
1817
-            marker = '●'  ! Filled circle for errors
1818
-            color = char(27) // '[31m'  ! Red
1819
-        case(SEVERITY_WARNING)
1820
-            marker = '▲'  ! Triangle for warnings
1821
-            color = char(27) // '[33m'  ! Yellow
1822
-        case(SEVERITY_INFO)
1823
-            marker = '◆'  ! Diamond for info
1824
-            color = char(27) // '[36m'  ! Cyan
1825
-        case(SEVERITY_HINT)
1826
-            marker = '○'  ! Empty circle for hints
1827
-            color = char(27) // '[90m'  ! Gray
1828
-        end select
1829
-    end subroutine get_diagnostic_marker
1794
+    ! UNUSED: Get diagnostic marker and color for a line
1795
+    ! Kept for potential future use
1796
+    ! subroutine get_diagnostic_marker(diagnostics, marker, color)
1797
+    !     type(diagnostic_t), intent(in) :: diagnostics(:)
1798
+    !     character(len=3), intent(out) :: marker  ! UTF-8 characters can be up to 3 bytes
1799
+    !     character(len=:), allocatable, intent(out) :: color
1800
+    !     integer :: i, max_severity
1801
+    !
1802
+    !     marker = ' '
1803
+    !     color = ''
1804
+    !
1805
+    !     if (size(diagnostics) == 0) return
1806
+    !
1807
+    !     ! Find highest severity diagnostic
1808
+    !     max_severity = SEVERITY_HINT
1809
+    !     do i = 1, size(diagnostics)
1810
+    !         if (diagnostics(i)%severity < max_severity) then
1811
+    !             max_severity = diagnostics(i)%severity
1812
+    !         end if
1813
+    !     end do
1814
+    !
1815
+    !     ! Set marker and color based on severity
1816
+    !     select case(max_severity)
1817
+    !     case(SEVERITY_ERROR)
1818
+    !         marker = '●'  ! Filled circle for errors
1819
+    !         color = char(27) // '[31m'  ! Red
1820
+    !     case(SEVERITY_WARNING)
1821
+    !         marker = '▲'  ! Triangle for warnings
1822
+    !         color = char(27) // '[33m'  ! Yellow
1823
+    !     case(SEVERITY_INFO)
1824
+    !         marker = '◆'  ! Diamond for info
1825
+    !         color = char(27) // '[36m'  ! Cyan
1826
+    !     case(SEVERITY_HINT)
1827
+    !         marker = '○'  ! Empty circle for hints
1828
+    !         color = char(27) // '[90m'  ! Gray
1829
+    !     end select
1830
+    ! end subroutine get_diagnostic_marker
18301831
 
18311832
     ! Render screen with LSP panel on the right (similar to render_screen_with_tree but for right side)
18321833
     subroutine render_screen_with_lsp_panel(buffer, editor, panel_type, match_mode_active, match_case_sens)
src/ui/diagnostics_panel_module.f90modified
@@ -326,65 +326,67 @@ contains
326326
         end do
327327
     end subroutine append_truncated_message
328328
 
329
-    ! Calculate how many lines a message needs when wrapped
330
-    function calc_wrapped_lines(message, width) result(num_lines)
331
-        character(len=*), intent(in) :: message
332
-        integer, intent(in) :: width
333
-        integer :: num_lines
334
-        integer :: msg_len, wrap_width
335
-
336
-        msg_len = len_trim(message)
337
-        wrap_width = width - 4  ! Leave space for indentation
338
-
339
-        if (msg_len <= wrap_width) then
340
-            num_lines = 1
341
-        else
342
-            num_lines = (msg_len + wrap_width - 1) / wrap_width
343
-        end if
344
-    end function calc_wrapped_lines
345
-
346
-    ! Render a wrapped line of a message (line_num is 1-based)
347
-    subroutine render_wrapped_line(message, line_num, width, start_col, is_selected)
348
-        character(len=*), intent(in) :: message
349
-        integer, intent(in) :: line_num, width, start_col
350
-        logical, intent(in) :: is_selected
351
-        character(len=256) :: output_buffer
352
-        integer :: msg_len, wrap_width, start_pos, end_pos, i
353
-
354
-        msg_len = len_trim(message)
355
-        wrap_width = width - 4  ! Leave space for indentation
356
-
357
-        ! Calculate which portion of message to show
358
-        start_pos = (line_num - 1) * wrap_width + 1
359
-        end_pos = min(start_pos + wrap_width - 1, msg_len)
360
-
361
-        ! Initialize buffer with spaces
362
-        output_buffer = repeat(' ', len(output_buffer))
363
-
364
-        ! Add indentation for continuation lines
365
-        output_buffer(1:4) = '    '
366
-
367
-        ! Copy message portion
368
-        if (start_pos <= msg_len) then
369
-            output_buffer(5:5 + end_pos - start_pos) = message(start_pos:end_pos)
370
-        end if
371
-
372
-        ! Pad to width
373
-        do i = len_trim(output_buffer) + 1, width
374
-            output_buffer(i:i) = ' '
375
-        end do
376
-
377
-        ! Set background color
378
-        if (is_selected) then
379
-            call terminal_write(char(27) // '[48;5;240m')  ! Highlight
380
-        else
381
-            call terminal_write(char(27) // '[48;5;235m')  ! Normal
382
-        end if
383
-
384
-        ! Write the line
385
-        call terminal_write(output_buffer(1:width))
386
-        call terminal_write(char(27) // '[0m')
387
-    end subroutine render_wrapped_line
329
+    ! UNUSED: Calculate how many lines a message needs when wrapped
330
+    ! Kept for potential future use
331
+    ! function calc_wrapped_lines(message, width) result(num_lines)
332
+    !     character(len=*), intent(in) :: message
333
+    !     integer, intent(in) :: width
334
+    !     integer :: num_lines
335
+    !     integer :: msg_len, wrap_width
336
+    !
337
+    !     msg_len = len_trim(message)
338
+    !     wrap_width = width - 4  ! Leave space for indentation
339
+    !
340
+    !     if (msg_len <= wrap_width) then
341
+    !         num_lines = 1
342
+    !     else
343
+    !         num_lines = (msg_len + wrap_width - 1) / wrap_width
344
+    !     end if
345
+    ! end function calc_wrapped_lines
346
+
347
+    ! UNUSED: Render a wrapped line of a message (line_num is 1-based)
348
+    ! Kept for potential future use
349
+    ! subroutine render_wrapped_line(message, line_num, width, start_col, is_selected)
350
+    !     character(len=*), intent(in) :: message
351
+    !     integer, intent(in) :: line_num, width, start_col
352
+    !     logical, intent(in) :: is_selected
353
+    !     character(len=256) :: output_buffer
354
+    !     integer :: msg_len, wrap_width, start_pos, end_pos, i
355
+    !
356
+    !     msg_len = len_trim(message)
357
+    !     wrap_width = width - 4  ! Leave space for indentation
358
+    !
359
+    !     ! Calculate which portion of message to show
360
+    !     start_pos = (line_num - 1) * wrap_width + 1
361
+    !     end_pos = min(start_pos + wrap_width - 1, msg_len)
362
+    !
363
+    !     ! Initialize buffer with spaces
364
+    !     output_buffer = repeat(' ', len(output_buffer))
365
+    !
366
+    !     ! Add indentation for continuation lines
367
+    !     output_buffer(1:4) = '    '
368
+    !
369
+    !     ! Copy message portion
370
+    !     if (start_pos <= msg_len) then
371
+    !         output_buffer(5:5 + end_pos - start_pos) = message(start_pos:end_pos)
372
+    !     end if
373
+    !
374
+    !     ! Pad to width
375
+    !     do i = len_trim(output_buffer) + 1, width
376
+    !         output_buffer(i:i) = ' '
377
+    !     end do
378
+    !
379
+    !     ! Set background color
380
+    !     if (is_selected) then
381
+    !         call terminal_write(char(27) // '[48;5;240m')  ! Highlight
382
+    !     else
383
+    !         call terminal_write(char(27) // '[48;5;235m')  ! Normal
384
+    !     end if
385
+    !
386
+    !     ! Write the line
387
+    !     call terminal_write(output_buffer(1:width))
388
+    !     call terminal_write(char(27) // '[0m')
389
+    ! end subroutine render_wrapped_line
388390
 
389391
     function diagnostics_panel_handle_key(panel, key) result(handled)
390392
         type(diagnostics_panel_t), intent(inout) :: panel
@@ -419,22 +421,24 @@ contains
419421
         end select
420422
     end function diagnostics_panel_handle_key
421423
 
422
-    function get_selected_diagnostic_location(panel, line, col) result(has_location)
423
-        type(diagnostics_panel_t), intent(in) :: panel
424
-        integer, intent(out) :: line, col
425
-        logical :: has_location
426
-
427
-        has_location = .false.
428
-        line = 1
429
-        col = 1
430
-
431
-        if (panel%visible .and. panel%diagnostic_count > 0 .and. &
432
-            panel%selected_index > 0 .and. panel%selected_index <= panel%diagnostic_count) then
433
-
434
-            line = panel%diagnostics(panel%selected_index)%range%start_line + 1  ! Convert to 1-based
435
-            col = panel%diagnostics(panel%selected_index)%range%start_col + 1
436
-            has_location = .true.
437
-        end if
438
-    end function get_selected_diagnostic_location
424
+    ! UNUSED: Get location of selected diagnostic
425
+    ! Kept for potential future use
426
+    ! function get_selected_diagnostic_location(panel, line, col) result(has_location)
427
+    !     type(diagnostics_panel_t), intent(in) :: panel
428
+    !     integer, intent(out) :: line, col
429
+    !     logical :: has_location
430
+    !
431
+    !     has_location = .false.
432
+    !     line = 1
433
+    !     col = 1
434
+    !
435
+    !     if (panel%visible .and. panel%diagnostic_count > 0 .and. &
436
+    !         panel%selected_index > 0 .and. panel%selected_index <= panel%diagnostic_count) then
437
+    !
438
+    !         line = panel%diagnostics(panel%selected_index)%range%start_line + 1  ! Convert to 1-based
439
+    !         col = panel%diagnostics(panel%selected_index)%range%start_col + 1
440
+    !         has_location = .true.
441
+    !     end if
442
+    ! end function get_selected_diagnostic_location
439443
 
440444
 end module diagnostics_panel_module
src/ui/signature_tooltip_module.f90modified
@@ -112,94 +112,96 @@ contains
112112
         tooltip%active_parameter = param_index
113113
     end subroutine set_active_parameter
114114
 
115
-    subroutine render_signature_tooltip(tooltip)
116
-        type(signature_tooltip_t), intent(in) :: tooltip
117
-        integer :: display_row, sig_idx
118
-        character(len=512) :: line
119
-        character(len=256) :: label
120
-        integer :: param_start, param_end, i
121
-
122
-        if (.not. tooltip%visible .or. tooltip%num_signatures == 0) return
123
-
124
-        sig_idx = tooltip%active_signature
125
-        if (sig_idx < 1 .or. sig_idx > tooltip%num_signatures) return
126
-
127
-        display_row = tooltip%row
128
-
129
-        ! Draw background
130
-        call terminal_move_cursor(display_row, tooltip%col)
131
-        call terminal_write(char(27) // '[48;5;238m')  ! Dark background
132
-
133
-        ! Build signature line with parameter highlighting
134
-        if (allocated(tooltip%signatures(sig_idx)%label)) then
135
-            label = tooltip%signatures(sig_idx)%label
136
-
137
-            ! If we have parameters, try to highlight the active one
138
-            if (tooltip%signatures(sig_idx)%num_parameters > 0 .and. &
139
-                tooltip%active_parameter > 0 .and. &
140
-                tooltip%active_parameter <= tooltip%signatures(sig_idx)%num_parameters) then
141
-
142
-                ! Get the parameter label to highlight
143
-                if (allocated(tooltip%signatures(sig_idx)%parameters(tooltip%active_parameter)%label)) then
144
-                    block
145
-                        character(len=:), allocatable :: param_label
146
-                        param_label = tooltip%signatures(sig_idx)%parameters(tooltip%active_parameter)%label
147
-
148
-                        ! Find parameter in signature
149
-                        param_start = index(label, trim(param_label))
150
-                        if (param_start > 0) then
151
-                            param_end = param_start + len_trim(param_label) - 1
152
-
153
-                            ! Build highlighted line
154
-                            line = " "
155
-                            if (param_start > 1) then
156
-                                line = trim(line) // label(1:param_start-1)
157
-                            end if
158
-
159
-                            ! Highlight the active parameter
160
-                            line = trim(line) // char(27) // '[1;33m'  ! Bold yellow
161
-                            line = trim(line) // label(param_start:param_end)
162
-                            line = trim(line) // char(27) // '[0;48;5;238m'  ! Reset to dark bg
163
-
164
-                            if (param_end < len_trim(label)) then
165
-                                line = trim(line) // label(param_end+1:len_trim(label))
166
-                            end if
167
-                            line = trim(line) // " "
168
-                        else
169
-                            ! Couldn't find parameter, show plain
170
-                            line = " " // trim(label) // " "
171
-                        end if
172
-                    end block
173
-                else
174
-                    line = " " // trim(label) // " "
175
-                end if
176
-            else
177
-                line = " " // trim(label) // " "
178
-            end if
179
-        else
180
-            line = " (no signature) "
181
-        end if
182
-
183
-        ! Truncate if too long
184
-        if (len_trim(line) > tooltip%max_width) then
185
-            line = line(1:tooltip%max_width-3) // "..."
186
-        end if
187
-
188
-        call terminal_write(trim(line))
189
-
190
-        ! Show which signature if multiple
191
-        if (tooltip%num_signatures > 1) then
192
-            block
193
-                character(len=20) :: sig_indicator
194
-                write(sig_indicator, '(A,I0,A,I0,A)') " (", sig_idx, "/", tooltip%num_signatures, ")"
195
-                call terminal_write(char(27) // '[90m')  ! Gray
196
-                call terminal_write(trim(sig_indicator))
197
-            end block
198
-        end if
199
-
200
-        ! Reset colors
201
-        call terminal_write(char(27) // '[0m')
202
-    end subroutine render_signature_tooltip
115
+    ! UNUSED: Render signature tooltip with parameter highlighting
116
+    ! Kept for potential future use
117
+    ! subroutine render_signature_tooltip(tooltip)
118
+    !     type(signature_tooltip_t), intent(in) :: tooltip
119
+    !     integer :: display_row, sig_idx
120
+    !     character(len=512) :: line
121
+    !     character(len=256) :: label
122
+    !     integer :: param_start, param_end, i
123
+    !
124
+    !     if (.not. tooltip%visible .or. tooltip%num_signatures == 0) return
125
+    !
126
+    !     sig_idx = tooltip%active_signature
127
+    !     if (sig_idx < 1 .or. sig_idx > tooltip%num_signatures) return
128
+    !
129
+    !     display_row = tooltip%row
130
+    !
131
+    !     ! Draw background
132
+    !     call terminal_move_cursor(display_row, tooltip%col)
133
+    !     call terminal_write(char(27) // '[48;5;238m')  ! Dark background
134
+    !
135
+    !     ! Build signature line with parameter highlighting
136
+    !     if (allocated(tooltip%signatures(sig_idx)%label)) then
137
+    !         label = tooltip%signatures(sig_idx)%label
138
+    !
139
+    !         ! If we have parameters, try to highlight the active one
140
+    !         if (tooltip%signatures(sig_idx)%num_parameters > 0 .and. &
141
+    !             tooltip%active_parameter > 0 .and. &
142
+    !             tooltip%active_parameter <= tooltip%signatures(sig_idx)%num_parameters) then
143
+    !
144
+    !             ! Get the parameter label to highlight
145
+    !             if (allocated(tooltip%signatures(sig_idx)%parameters(tooltip%active_parameter)%label)) then
146
+    !                 block
147
+    !                     character(len=:), allocatable :: param_label
148
+    !                     param_label = tooltip%signatures(sig_idx)%parameters(tooltip%active_parameter)%label
149
+    !
150
+    !                     ! Find parameter in signature
151
+    !                     param_start = index(label, trim(param_label))
152
+    !                     if (param_start > 0) then
153
+    !                         param_end = param_start + len_trim(param_label) - 1
154
+    !
155
+    !                         ! Build highlighted line
156
+    !                         line = " "
157
+    !                         if (param_start > 1) then
158
+    !                             line = trim(line) // label(1:param_start-1)
159
+    !                         end if
160
+    !
161
+    !                         ! Highlight the active parameter
162
+    !                         line = trim(line) // char(27) // '[1;33m'  ! Bold yellow
163
+    !                         line = trim(line) // label(param_start:param_end)
164
+    !                         line = trim(line) // char(27) // '[0;48;5;238m'  ! Reset to dark bg
165
+    !
166
+    !                         if (param_end < len_trim(label)) then
167
+    !                             line = trim(line) // label(param_end+1:len_trim(label))
168
+    !                         end if
169
+    !                         line = trim(line) // " "
170
+    !                     else
171
+    !                         ! Couldn't find parameter, show plain
172
+    !                         line = " " // trim(label) // " "
173
+    !                     end if
174
+    !                 end block
175
+    !             else
176
+    !                 line = " " // trim(label) // " "
177
+    !             end if
178
+    !         else
179
+    !             line = " " // trim(label) // " "
180
+    !         end if
181
+    !     else
182
+    !         line = " (no signature) "
183
+    !     end if
184
+    !
185
+    !     ! Truncate if too long
186
+    !     if (len_trim(line) > tooltip%max_width) then
187
+    !         line = line(1:tooltip%max_width-3) // "..."
188
+    !     end if
189
+    !
190
+    !     call terminal_write(trim(line))
191
+    !
192
+    !     ! Show which signature if multiple
193
+    !     if (tooltip%num_signatures > 1) then
194
+    !         block
195
+    !             character(len=20) :: sig_indicator
196
+    !             write(sig_indicator, '(A,I0,A,I0,A)') " (", sig_idx, "/", tooltip%num_signatures, ")"
197
+    !             call terminal_write(char(27) // '[90m')  ! Gray
198
+    !             call terminal_write(trim(sig_indicator))
199
+    !         end block
200
+    !     end if
201
+    !
202
+    !     ! Reset colors
203
+    !     call terminal_write(char(27) // '[0m')
204
+    ! end subroutine render_signature_tooltip
203205
 
204206
     subroutine handle_signature_response(tooltip, response)
205207
         use lsp_protocol_module, only: lsp_message_t