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