Initial public release of Warp.

Repo-Sync-Origin: warpdotdev/warp-internal@12af1d983b
This commit is contained in:
David Stern
2026-04-28 08:43:33 -05:00
commit 0dbd3d567a
4982 changed files with 1431549 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
use std::path::{Path, PathBuf};
use lsp::supported_servers::LSPServerType;
use sha2::{Digest, Sha256};
use simple_logger::manager::resolve_log_path;
/// Returns the relative log path (within the LSP log directory) for an LSP server.
/// For example, `rust-analyzer/12345678.log`.
pub fn relative_log_path(server_type: LSPServerType, workspace_path: &Path) -> PathBuf {
let server_type_name = server_type.binary_name();
let workspace_hash = hash_workspace_path(workspace_path);
PathBuf::from(server_type_name).join(format!("{workspace_hash}.log"))
}
/// Returns the path to the log file for an LSP server.
///
/// Format: `{secure_state_dir}/lsp/{server_type}/{workspace_hash}.log`
///
/// The workspace path is hashed to avoid filesystem issues with long or special character paths.
pub fn log_file_path(server_type: LSPServerType, workspace_path: &Path) -> PathBuf {
resolve_log_path("lsp", relative_log_path(server_type, workspace_path))
}
/// Hashes the workspace path to create a filesystem-safe identifier.
/// Uses first 16 characters of SHA256 hex digest (64 bits of entropy).
fn hash_workspace_path(path: &Path) -> String {
let mut hasher = Sha256::new();
hasher.update(path.to_string_lossy().as_bytes());
let result = hasher.finalize();
// Take first 8 bytes (16 hex chars) for a shorter but still unique identifier
hex::encode(&result[..8])
}