fortrangoingonforty/facsimile / 3c9948a

Browse files

Bump version to 0.9.5

- Fix LSP server installer crash: exit raw mode before execute_command_line
- Add cmdstat parameter to prevent Fortran runtime errors on command failure
- Switch Python LSP installs from pip to pipx for isolated environments
Authored by espadonne
SHA
3c9948a10cdf1ad6e5bd012ba345e7532fe71aa7
Parents
d27a852
Tree
6e80e30

5 changed files

StatusFile+-
M .gitignore 1 0
M VERSION 1 1
M src/lsp/server_detection_module.f90 4 4
M src/lsp/server_installer_module.f90 32 4
M src/version_module.f90 1 1
.gitignoremodified
@@ -11,3 +11,4 @@ fac_debug.txt
1111
 # Scratch/notes
1212
 old/
1313
 CLAUDE.md
14
+CLAUDE.md
VERSIONmodified
@@ -1,1 +1,1 @@
1
-0.9.4
1
+0.9.5
src/lsp/server_detection_module.f90modified
@@ -51,7 +51,7 @@ contains
5151
         ! Python - Pyright
5252
         servers(i)%name = 'pyright'
5353
         servers(i)%language = 'Python'
54
-        servers(i)%install_cmd = 'pip install pyright'
54
+        servers(i)%install_cmd = 'pipx install pyright'
5555
         servers(i)%description = 'Python type checker and language server'
5656
         servers(i)%check_cmd = 'pyright-langserver'
5757
         i = i + 1
@@ -59,7 +59,7 @@ contains
5959
         ! Python - Ruff
6060
         servers(i)%name = 'ruff'
6161
         servers(i)%language = 'Python'
62
-        servers(i)%install_cmd = 'pip install ruff'
62
+        servers(i)%install_cmd = 'pipx install ruff'
6363
         servers(i)%description = 'Fast Python linter with auto-fix'
6464
         servers(i)%check_cmd = 'ruff'
6565
         i = i + 1
@@ -67,7 +67,7 @@ contains
6767
         ! Python - python-lsp-server
6868
         servers(i)%name = 'python-lsp-server'
6969
         servers(i)%language = 'Python'
70
-        servers(i)%install_cmd = 'pip install python-lsp-server'
70
+        servers(i)%install_cmd = 'pipx install python-lsp-server'
7171
         servers(i)%description = 'Python LSP (pylsp) with plugins support'
7272
         servers(i)%check_cmd = 'pylsp'
7373
         i = i + 1
@@ -203,7 +203,7 @@ contains
203203
         ! Fortran - fortls
204204
         servers(i)%name = 'fortls'
205205
         servers(i)%language = 'Fortran'
206
-        servers(i)%install_cmd = 'pip install fortls'
206
+        servers(i)%install_cmd = 'pipx install fortls'
207207
         servers(i)%description = 'Fortran language server'
208208
         servers(i)%check_cmd = 'fortls'
209209
     end subroutine init_known_servers
src/lsp/server_installer_module.f90modified
@@ -1,4 +1,6 @@
11
 module server_installer_module
2
+    use raw_mode_module, only: disable_raw_mode, enable_raw_mode
3
+    use terminal_io_module, only: terminal_clear_screen, terminal_show_cursor
24
     implicit none
35
     private
46
 
@@ -16,7 +18,8 @@ contains
1618
     function run_install_command(command) result(result)
1719
         character(len=*), intent(in) :: command
1820
         type(install_result_t) :: result
19
-        integer :: exit_status
21
+        integer :: exit_status, cmd_status
22
+        logical :: raw_disabled
2023
 
2124
         result%success = .false.
2225
         result%exit_code = -1
@@ -27,9 +30,27 @@ contains
2730
             return
2831
         end if
2932
 
30
-        ! Execute the command
31
-        ! Note: This runs synchronously and blocks until complete
32
-        call execute_command_line(trim(command), wait=.true., exitstat=exit_status)
33
+        ! Must exit raw mode before running external commands
34
+        ! Otherwise child process inherits broken terminal state
35
+        raw_disabled = disable_raw_mode()
36
+
37
+        ! Show cursor and clear screen for command output
38
+        call terminal_show_cursor()
39
+        call terminal_clear_screen()
40
+
41
+        ! Execute the command with cmdstat to catch errors gracefully
42
+        ! Without cmdstat, invalid commands cause Fortran runtime errors
43
+        call execute_command_line(trim(command), wait=.true., exitstat=exit_status, cmdstat=cmd_status)
44
+
45
+        ! Re-enable raw mode for editor
46
+        raw_disabled = enable_raw_mode()
47
+
48
+        ! Check for command execution errors (cmdstat /= 0 means execute failed)
49
+        if (cmd_status /= 0) then
50
+            result%exit_code = cmd_status
51
+            result%message = 'Failed to execute command (cmdstat=' // trim(itoa(cmd_status)) // ')'
52
+            return
53
+        end if
3354
 
3455
         result%exit_code = exit_status
3556
         result%success = (exit_status == 0)
@@ -41,4 +62,11 @@ contains
4162
         end if
4263
     end function run_install_command
4364
 
65
+    ! Simple integer to string helper
66
+    function itoa(i) result(str)
67
+        integer, intent(in) :: i
68
+        character(len=20) :: str
69
+        write(str, '(I0)') i
70
+    end function itoa
71
+
4472
 end module server_installer_module
src/version_module.f90modified
@@ -1,4 +1,4 @@
11
 module version_module
22
     implicit none
3
-    character(len=*), parameter :: VERSION = '0.9.4'
3
+    character(len=*), parameter :: VERSION = '0.9.5'
44
 end module version_module