Skip to content
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
26 changes: 26 additions & 0 deletions rust/lithe-core/src/lsp/interface/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ use std::path::PathBuf;
use std::process::{Child, ChildStdin, Command, Stdio};
use std::sync::{Arc, Mutex};

#[cfg(target_os = "windows")]
use std::os::windows::process::CommandExt;

/// Everything needed to start a language server, after provider adaptation has
/// already rewritten the arguments.
pub struct LspProcessSpec {
Expand Down Expand Up @@ -75,6 +78,7 @@ impl LspProcessLauncher for SystemProcessLauncher {
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.stderr(Stdio::piped());
apply_language_server_creation_flags(&mut command);
let mut child = command.spawn().map_err(|error| {
CoreError::new(
ErrorCode::ProcessStartFailed,
Expand Down Expand Up @@ -102,6 +106,20 @@ impl LspProcessLauncher for SystemProcessLauncher {
}
}

fn apply_language_server_creation_flags(command: &mut Command) {
#[cfg(target_os = "windows")]
command.creation_flags(language_server_process_creation_flags());

#[cfg(not(target_os = "windows"))]
let _ = command;
}

#[cfg(target_os = "windows")]
fn language_server_process_creation_flags() -> u32 {
const CREATE_NO_WINDOW: u32 = 0x0800_0000;
CREATE_NO_WINDOW
}

struct SystemProcess {
input: Mutex<Option<ChildStdin>>,
child: Mutex<Child>,
Expand Down Expand Up @@ -166,3 +184,11 @@ fn missing_stream(stream: &str) -> CoreError {
)
.with_details(stream)
}

#[cfg(all(test, target_os = "windows"))]
mod tests {
#[test]
fn background_language_servers_do_not_create_windows_console() {
assert_eq!(super::language_server_process_creation_flags(), 0x0800_0000);
}
}
20 changes: 18 additions & 2 deletions windows/tauri/src-tauri/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,12 @@ mod tests {
assert!(widths.contains(&32), "{widths:?}");
assert!(widths.contains(&256), "{widths:?}");
}

#[cfg(target_os = "windows")]
#[test]
fn background_font_queries_do_not_create_windows_console() {
assert_eq!(super::font_query_process_creation_flags(), 0x0800_0000);
}
}

#[tauri::command]
Expand Down Expand Up @@ -431,13 +437,17 @@ pub fn validate_font(font_family: String) -> bool {

#[cfg(target_os = "windows")]
fn platform_fonts() -> Vec<FontInfo> {
use std::os::windows::process::CommandExt;
use std::process::Command;
let output = Command::new("reg.exe")

let mut command = Command::new("reg.exe");
command
.args([
"query",
r"HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts",
])
.output();
.creation_flags(font_query_process_creation_flags());
let output = command.output();
let text = output
.ok()
.filter(|value| value.status.success())
Expand Down Expand Up @@ -468,6 +478,12 @@ fn platform_fonts() -> Vec<FontInfo> {
.collect()
}

#[cfg(target_os = "windows")]
fn font_query_process_creation_flags() -> u32 {
const CREATE_NO_WINDOW: u32 = 0x0800_0000;
CREATE_NO_WINDOW
}

#[cfg(not(target_os = "windows"))]
fn platform_fonts() -> Vec<FontInfo> {
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ test("project tab bar exposes accessible switchable and closable project tabs",
expect(source).toContain('t("titleProject.closeProject", { name: project.name })');
expect(source).toContain("group-hover:opacity-100");
expect(source).toContain("group-focus-within:opacity-100");
expect(source).toContain(
"absolute inset-y-0 right-1 z-10 flex items-center transition-opacity",
);
expect(source).not.toContain("-translate-y-1/2");
});
31 changes: 17 additions & 14 deletions windows/tauri/src/features/window/components/project-tab-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,26 +75,29 @@ export function ProjectTabBar() {
/>
) : null}
</button>
<Button
type="button"
size="icon-xs"
variant="ghost"
aria-label={closeLabel}
tooltip={closeLabel}
disabled={isProjectActionPending}
onClick={(event) => {
event.stopPropagation();
void handleCloseProject(project.id);
}}
<div
className={cn(
"absolute top-1/2 right-1 z-10 -translate-y-1/2 transition-opacity",
"absolute inset-y-0 right-1 z-10 flex items-center transition-opacity",
project.isActive
? "opacity-100"
: "pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100",
)}
>
<X className="pointer-events-none select-none" aria-hidden="true" />
</Button>
<Button
type="button"
size="icon-xs"
variant="ghost"
aria-label={closeLabel}
tooltip={closeLabel}
disabled={isProjectActionPending}
onClick={(event) => {
event.stopPropagation();
void handleCloseProject(project.id);
}}
>
<X className="pointer-events-none select-none" aria-hidden="true" />
</Button>
</div>
</div>
);
})}
Expand Down
Loading