Порівняти коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
3c783e8b5a | ||
|
|
8568ff001b | ||
|
|
2a8e5e791d | ||
|
|
3b608355a3 | ||
|
|
50308a956d |
No files matched your search
@@ -4146,6 +4146,7 @@ dependencies = [
|
||||
name = "ide-jsonrpc"
|
||||
version = "0.1.17"
|
||||
dependencies = [
|
||||
"encoding_rs",
|
||||
"futures",
|
||||
"ide-core",
|
||||
"parking_lot",
|
||||
|
||||
@@ -100,17 +100,6 @@ c → cpp, php_only), node names adapted to the bundled grammar versions
|
||||
definitions re-kinded as `field` / `method`, and missing scopes, definitions and
|
||||
references added; each file's header notes its changes.
|
||||
|
||||
## Theme plugin palettes
|
||||
|
||||
The sample theme plugins port MIT-licensed palettes; each package's `LICENSE`
|
||||
holds the full notice and source revisions:
|
||||
|
||||
- `plugins/theme-solarized/`: [Solarized](https://github.com/altercation/solarized),
|
||||
Copyright (c) 2011 Ethan Schoonover.
|
||||
- `plugins/theme-one/`: Atom [One Light](https://github.com/atom/one-light-syntax) /
|
||||
[One Dark](https://github.com/atom/one-dark-syntax) syntax themes, Copyright (c) 2016
|
||||
GitHub Inc., and their UI themes, Copyright (c) 2014 GitHub Inc.
|
||||
|
||||
---
|
||||
|
||||
Apache License
|
||||
@@ -168,3 +157,86 @@ If the Work includes a "NOTICE" text file as part of its distribution, then any
|
||||
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
## Solarized
|
||||
|
||||
The Solarized palettes in `src/styles/tokens.css` are adapted from
|
||||
[Ethan Schoonover’s Solarized](https://github.com/altercation/solarized/tree/62f656a02f93c5190a8753159e34b385588d5ff3).
|
||||
See [theme sources and mapping](docs/themes.md). MIT license:
|
||||
|
||||
```text
|
||||
Copyright (c) 2011 Ethan Schoonover
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
```
|
||||
|
||||
## Atom One Light and One Dark
|
||||
|
||||
The One palettes and semantic syntax mapping in `src/styles/tokens.css` are
|
||||
adapted from GitHub’s Atom One syntax and UI themes.
|
||||
Source revisions are listed in [theme sources and mapping](docs/themes.md).
|
||||
Both syntax themes use the following MIT notice:
|
||||
|
||||
```text
|
||||
Copyright (c) 2016 GitHub Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
```
|
||||
|
||||
Both UI themes use the following MIT notice:
|
||||
|
||||
```text
|
||||
Copyright (c) 2014 GitHub Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
```
|
||||
@@ -14,7 +14,7 @@ use std::pin::Pin;
|
||||
use std::process::Stdio;
|
||||
use std::sync::Arc;
|
||||
use std::time::{Duration, Instant};
|
||||
use tokio::io::{AsyncBufReadExt, AsyncRead, AsyncWrite, BufReader};
|
||||
use tokio::io::{AsyncRead, AsyncWrite};
|
||||
use tokio::process::{Child, Command};
|
||||
|
||||
pub const PORT_PLACEHOLDER: &str = "${port}";
|
||||
@@ -457,17 +457,19 @@ fn pump_lines<R: AsyncRead + Unpin + Send + 'static>(
|
||||
name: String,
|
||||
sink: Arc<parking_lot::Mutex<Vec<String>>>,
|
||||
) {
|
||||
tokio::spawn(async move {
|
||||
let mut lines = BufReader::new(stream).lines();
|
||||
while let Ok(Some(line)) = lines.next_line().await {
|
||||
tracing::debug!(target: "ide_dap::adapter", "[{name}] {line}");
|
||||
let mut buf = sink.lock();
|
||||
if buf.len() >= 40 {
|
||||
buf.remove(0);
|
||||
}
|
||||
buf.push(line);
|
||||
}
|
||||
});
|
||||
tokio::spawn(ide_jsonrpc::output::read_lines(stream, move |line| {
|
||||
tracing::debug!(target: "ide_dap::adapter", "[{name}] {line}");
|
||||
push_line(&sink, line);
|
||||
}));
|
||||
}
|
||||
|
||||
/// Appends to the recent-output buffer of an adapter (the last 40 lines).
|
||||
pub(crate) fn push_line(sink: &parking_lot::Mutex<Vec<String>>, line: String) {
|
||||
let mut buf = sink.lock();
|
||||
if buf.len() >= 40 {
|
||||
buf.remove(0);
|
||||
}
|
||||
buf.push(line);
|
||||
}
|
||||
|
||||
const LOOPBACK: &str = "127.0.0.1";
|
||||
|
||||
@@ -95,7 +95,21 @@ pub struct Connection {
|
||||
|
||||
impl Connection {
|
||||
/// Starts reader/writer tasks over `reader`/`writer`. Must be called inside a Tokio runtime.
|
||||
pub fn start<R, W>(reader: R, mut writer: W) -> (Self, mpsc::UnboundedReceiver<Incoming>)
|
||||
pub fn start<R, W>(reader: R, writer: W) -> (Self, mpsc::UnboundedReceiver<Incoming>)
|
||||
where
|
||||
R: AsyncRead + Unpin + Send + 'static,
|
||||
W: AsyncWrite + Unpin + Send + 'static,
|
||||
{
|
||||
Self::start_with_output(reader, writer, Box::new(|_| {}))
|
||||
}
|
||||
|
||||
/// [`start`](Self::start) that hands lines outside the protocol (an adapter's
|
||||
/// own output on stdout, decoded) to `on_output`.
|
||||
pub fn start_with_output<R, W>(
|
||||
reader: R,
|
||||
mut writer: W,
|
||||
on_output: Box<dyn Fn(String) + Send + Sync>,
|
||||
) -> (Self, mpsc::UnboundedReceiver<Incoming>)
|
||||
where
|
||||
R: AsyncRead + Unpin + Send + 'static,
|
||||
W: AsyncWrite + Unpin + Send + 'static,
|
||||
@@ -133,9 +147,14 @@ impl Connection {
|
||||
let reader_inner = inner.clone();
|
||||
tokio::spawn(async move {
|
||||
let mut reader = BufReader::new(reader);
|
||||
let mut noise = |line: &[u8]| {
|
||||
let text = ide_jsonrpc::output::decode(line);
|
||||
tracing::warn!("dap: output outside the protocol: {text}");
|
||||
on_output(text);
|
||||
};
|
||||
loop {
|
||||
let msg = tokio::select! {
|
||||
msg = framing::read_message(&mut reader) => msg,
|
||||
msg = framing::read_message_or_noise(&mut reader, &mut noise) => msg,
|
||||
_ = reader_inner.cancel.cancelled() => break,
|
||||
};
|
||||
match msg {
|
||||
|
||||
@@ -681,7 +681,10 @@ impl DebugManager {
|
||||
}
|
||||
let io = self.launcher.launch(spec.clone(), reuse_port).await?;
|
||||
let stderr = io.stderr.clone();
|
||||
let (conn, incoming) = Connection::start(io.reader, io.writer);
|
||||
let (conn, incoming) = {
|
||||
let stderr = stderr.clone();
|
||||
Connection::start_with_output(io.reader, io.writer, Box::new(move |line| adapter::push_line(&stderr, line)))
|
||||
};
|
||||
let session =
|
||||
Arc::new(Session::new(id, owner, name, adapter_name, parent, request, conn, spec, io.port, io.child));
|
||||
self.sessions.lock().insert(id, session.clone());
|
||||
|
||||
@@ -15,3 +15,4 @@ futures.workspace = true
|
||||
parking_lot.workspace = true
|
||||
thiserror.workspace = true
|
||||
tracing.workspace = true
|
||||
encoding_rs.workspace = true
|
||||
@@ -6,7 +6,10 @@
|
||||
//! * [`Peer`]: a JSON-RPC 2.0 endpoint with request/response correlation,
|
||||
//! cancellation (`$/cancelRequest`) and handlers for server→client traffic.
|
||||
|
||||
pub mod output;
|
||||
|
||||
pub mod framing {
|
||||
use crate::output::trim_line_end as trim_line;
|
||||
use std::io::{Error, ErrorKind};
|
||||
use tokio::io::{AsyncBufRead, AsyncBufReadExt, AsyncReadExt, AsyncWrite, AsyncWriteExt};
|
||||
|
||||
@@ -21,6 +24,19 @@ pub mod framing {
|
||||
/// matched case-insensitively, unknown headers (e.g. `Content-Type`) are
|
||||
/// ignored, and both `\r\n` and bare `\n` line endings are accepted.
|
||||
pub async fn read_message<R: AsyncBufRead + Unpin>(reader: &mut R) -> std::io::Result<Option<Vec<u8>>> {
|
||||
read_message_or_noise(reader, &mut |line| {
|
||||
tracing::warn!("jsonrpc: ignoring output outside the protocol: {}", crate::output::decode(line));
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
/// [`read_message`] that hands lines which can't start a message header (a
|
||||
/// launcher's or runtime's own output on stdout, in any encoding) to `on_noise`
|
||||
/// and skips them, instead of failing on them.
|
||||
pub async fn read_message_or_noise<R: AsyncBufRead + Unpin>(
|
||||
reader: &mut R,
|
||||
on_noise: &mut (dyn FnMut(&[u8]) + Send),
|
||||
) -> std::io::Result<Option<Vec<u8>>> {
|
||||
let mut content_length: Option<usize> = None;
|
||||
let mut saw_any = false;
|
||||
let mut line = Vec::with_capacity(64);
|
||||
@@ -37,6 +53,11 @@ pub mod framing {
|
||||
if n as u64 >= MAX_HEADER_LINE {
|
||||
return Err(Error::new(ErrorKind::InvalidData, "header line too long"));
|
||||
}
|
||||
if !saw_any && header(&line).is_none() {
|
||||
// Output without a final newline, then EOF (`pause` waiting for a key).
|
||||
on_noise(trim_line(&line));
|
||||
return Ok(None);
|
||||
}
|
||||
return Err(Error::new(ErrorKind::UnexpectedEof, "EOF inside message header"));
|
||||
}
|
||||
let text = trim_line(&line);
|
||||
@@ -50,12 +71,18 @@ pub mod framing {
|
||||
// Tolerate stray blank lines between messages.
|
||||
continue;
|
||||
}
|
||||
saw_any = true;
|
||||
let text = std::str::from_utf8(text).map_err(|_| Error::new(ErrorKind::InvalidData, "non-UTF-8 header"))?;
|
||||
let Some((name, value)) = text.split_once(':') else {
|
||||
return Err(Error::new(ErrorKind::InvalidData, format!("malformed header line: {text:?}")));
|
||||
let Some((name, value)) = header(text) else {
|
||||
if !saw_any {
|
||||
on_noise(text);
|
||||
continue;
|
||||
}
|
||||
return Err(Error::new(
|
||||
ErrorKind::InvalidData,
|
||||
format!("malformed header line: {:?}", crate::output::decode(text)),
|
||||
));
|
||||
};
|
||||
if name.trim().eq_ignore_ascii_case("content-length") {
|
||||
saw_any = true;
|
||||
if name.eq_ignore_ascii_case("content-length") {
|
||||
let len: usize = value
|
||||
.trim()
|
||||
.parse()
|
||||
@@ -72,12 +99,12 @@ pub mod framing {
|
||||
Ok(Some(body))
|
||||
}
|
||||
|
||||
fn trim_line(line: &[u8]) -> &[u8] {
|
||||
let mut end = line.len();
|
||||
while end > 0 && matches!(line[end - 1], b'\n' | b'\r') {
|
||||
end -= 1;
|
||||
}
|
||||
&line[..end]
|
||||
/// `name: value` with a header-like name (a token, no spaces), else `None`.
|
||||
fn header(line: &[u8]) -> Option<(&str, &str)> {
|
||||
let text = std::str::from_utf8(trim_line(line)).ok()?;
|
||||
let (name, value) = text.split_once(':')?;
|
||||
let token = !name.is_empty() && name.bytes().all(|b| b.is_ascii_alphanumeric() || b == b'-' || b == b'_');
|
||||
token.then_some((name, value))
|
||||
}
|
||||
|
||||
/// Writes one framed message and flushes once.
|
||||
@@ -126,7 +153,7 @@ use serde_json::{Value, json};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, AtomicI64, Ordering};
|
||||
use tokio::io::{AsyncBufReadExt, AsyncRead, AsyncWrite, BufReader};
|
||||
use tokio::io::{AsyncRead, AsyncWrite, BufReader};
|
||||
use tokio::sync::{mpsc, oneshot, watch};
|
||||
use tokio_util::sync::CancellationToken;
|
||||
|
||||
@@ -205,6 +232,8 @@ struct Inner {
|
||||
/// Fired by [`Peer::kill`]; stops tasks and kills the child.
|
||||
kill: CancellationToken,
|
||||
pid: Option<u32>,
|
||||
/// Fired when the reader task has stopped (EOF, error or kill).
|
||||
reader_done: CancellationToken,
|
||||
}
|
||||
|
||||
impl Inner {
|
||||
@@ -250,10 +279,20 @@ pub enum Framing {
|
||||
}
|
||||
|
||||
impl Framing {
|
||||
async fn read<R: tokio::io::AsyncBufRead + Unpin>(self, reader: &mut R) -> std::io::Result<Option<Vec<u8>>> {
|
||||
async fn read<R: tokio::io::AsyncBufRead + Unpin>(
|
||||
self,
|
||||
reader: &mut R,
|
||||
on_noise: &mut (dyn FnMut(&[u8]) + Send),
|
||||
) -> std::io::Result<Option<Vec<u8>>> {
|
||||
match self {
|
||||
Framing::ContentLength => framing::read_message(reader).await,
|
||||
Framing::Lines => framing::read_line_message(reader).await,
|
||||
Framing::ContentLength => framing::read_message_or_noise(reader, on_noise).await,
|
||||
Framing::Lines => loop {
|
||||
let Some(line) = framing::read_line_message(reader).await? else { return Ok(None) };
|
||||
match line.iter().find(|b| !b.is_ascii_whitespace()) {
|
||||
Some(b'{' | b'[') => return Ok(Some(line)),
|
||||
_ => on_noise(&line),
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,6 +304,9 @@ impl Framing {
|
||||
}
|
||||
}
|
||||
|
||||
/// How long a process that exited is given for its last output to be read.
|
||||
const OUTPUT_DRAIN: std::time::Duration = std::time::Duration::from_secs(1);
|
||||
|
||||
/// A connected JSON-RPC peer. Cloning shares the connection.
|
||||
#[derive(Clone)]
|
||||
pub struct Peer {
|
||||
@@ -282,8 +324,9 @@ impl Drop for KillOnDrop {
|
||||
}
|
||||
|
||||
impl Peer {
|
||||
/// Spawns `command` and speaks JSON-RPC over its stdio. Stderr lines are
|
||||
/// forwarded to `tracing` and to `on_stderr`.
|
||||
/// Spawns `command` and speaks JSON-RPC over its stdio. Stderr lines, and
|
||||
/// stdout lines that are not part of a message (a launcher's own output), are
|
||||
/// decoded (see [`output::decode`]) and forwarded to `tracing` and to `on_stderr`.
|
||||
///
|
||||
/// Must be called from within a Tokio runtime.
|
||||
pub fn spawn(
|
||||
@@ -324,42 +367,44 @@ impl Peer {
|
||||
let stderr = child.stderr.take();
|
||||
let pid = child.id();
|
||||
|
||||
let peer = Self::start(stdout, stdin, handler, false, pid, framing);
|
||||
let on_output: Arc<dyn Fn(String) + Send + Sync> = Arc::from(on_stderr);
|
||||
let peer = Self::start(stdout, stdin, handler, false, pid, framing, Some(on_output.clone()));
|
||||
|
||||
if let Some(stderr) = stderr {
|
||||
let stderr_task = stderr.map(|stderr| {
|
||||
let name = command.to_owned();
|
||||
tokio::spawn(async move {
|
||||
let mut reader = BufReader::new(stderr);
|
||||
let mut line = Vec::new();
|
||||
loop {
|
||||
line.clear();
|
||||
match reader.read_until(b'\n', &mut line).await {
|
||||
Ok(0) | Err(_) => break,
|
||||
Ok(_) => {
|
||||
let text = String::from_utf8_lossy(&line).trim_end_matches(['\r', '\n']).to_owned();
|
||||
tracing::debug!(target: "ide_jsonrpc::stderr", "[{name}] {text}");
|
||||
on_stderr(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
tokio::spawn(output::read_lines(stderr, move |text| {
|
||||
tracing::debug!(target: "ide_jsonrpc::stderr", "[{name}] {text}");
|
||||
on_output(text);
|
||||
}))
|
||||
});
|
||||
|
||||
peer.supervise(child);
|
||||
peer.supervise(child, stderr_task);
|
||||
Ok(peer)
|
||||
}
|
||||
|
||||
/// Kills `child` when the connection is torn down; closes the connection when it exits.
|
||||
fn supervise(&self, mut child: tokio::process::Child) {
|
||||
/// After an exit of its own, the connection is reported closed only once what the
|
||||
/// process wrote last (stderr, stray stdout) has been read, so a crash report has it.
|
||||
fn supervise(&self, mut child: tokio::process::Child, stderr_task: Option<tokio::task::JoinHandle<()>>) {
|
||||
let inner = self.inner.clone();
|
||||
tokio::spawn(async move {
|
||||
let status = tokio::select! {
|
||||
status = child.wait() => status.ok(),
|
||||
let (status, killed) = tokio::select! {
|
||||
status = child.wait() => (status.ok(), false),
|
||||
_ = inner.kill.cancelled() => {
|
||||
let _ = child.start_kill();
|
||||
child.wait().await.ok()
|
||||
(child.wait().await.ok(), true)
|
||||
}
|
||||
};
|
||||
if !killed {
|
||||
// Bounded: a grandchild may keep the pipes open.
|
||||
let drained = async {
|
||||
if let Some(task) = stderr_task {
|
||||
let _ = task.await;
|
||||
}
|
||||
inner.reader_done.cancelled().await;
|
||||
};
|
||||
let _ = tokio::time::timeout(OUTPUT_DRAIN, drained).await;
|
||||
}
|
||||
inner.mark_closed(status.and_then(|s| s.code()));
|
||||
});
|
||||
}
|
||||
@@ -373,7 +418,7 @@ impl Peer {
|
||||
R: AsyncRead + Unpin + Send + 'static,
|
||||
W: AsyncWrite + Unpin + Send + 'static,
|
||||
{
|
||||
Self::start(reader, writer, handler, true, None, Framing::ContentLength)
|
||||
Self::start(reader, writer, handler, true, None, Framing::ContentLength, None)
|
||||
}
|
||||
|
||||
/// [`connect`](Self::connect) with the given wire framing.
|
||||
@@ -382,7 +427,7 @@ impl Peer {
|
||||
R: AsyncRead + Unpin + Send + 'static,
|
||||
W: AsyncWrite + Unpin + Send + 'static,
|
||||
{
|
||||
Self::start(reader, writer, handler, true, None, framing)
|
||||
Self::start(reader, writer, handler, true, None, framing, None)
|
||||
}
|
||||
|
||||
/// [`Peer::connect`] over streams served by `child` (a server reached over a socket
|
||||
@@ -399,8 +444,8 @@ impl Peer {
|
||||
R: AsyncRead + Unpin + Send + 'static,
|
||||
W: AsyncWrite + Unpin + Send + 'static,
|
||||
{
|
||||
let peer = Self::start(reader, writer, handler, true, child.id(), Framing::ContentLength);
|
||||
peer.supervise(child);
|
||||
let peer = Self::start(reader, writer, handler, true, child.id(), Framing::ContentLength, None);
|
||||
peer.supervise(child, None);
|
||||
peer
|
||||
}
|
||||
|
||||
@@ -411,6 +456,7 @@ impl Peer {
|
||||
close_on_eof: bool,
|
||||
pid: Option<u32>,
|
||||
framing: Framing,
|
||||
on_noise: Option<Arc<dyn Fn(String) + Send + Sync>>,
|
||||
) -> Self
|
||||
where
|
||||
R: AsyncRead + Unpin + Send + 'static,
|
||||
@@ -426,6 +472,7 @@ impl Peer {
|
||||
closed,
|
||||
kill: CancellationToken::new(),
|
||||
pid,
|
||||
reader_done: CancellationToken::new(),
|
||||
});
|
||||
|
||||
// Writer: a single task drains the queue so messages never interleave.
|
||||
@@ -476,20 +523,39 @@ impl Peer {
|
||||
let inner = inner.clone();
|
||||
tokio::spawn(async move {
|
||||
let mut reader = BufReader::new(reader);
|
||||
let seen_message = AtomicBool::new(false);
|
||||
let mut noise = |line: &[u8]| {
|
||||
let text = output::decode(line);
|
||||
if seen_message.load(Ordering::Relaxed) {
|
||||
tracing::debug!("jsonrpc: output outside the protocol: {text}");
|
||||
} else {
|
||||
tracing::warn!("jsonrpc: output before the first message: {text}");
|
||||
}
|
||||
if let Some(f) = &on_noise {
|
||||
f(text);
|
||||
}
|
||||
};
|
||||
loop {
|
||||
let msg = tokio::select! {
|
||||
msg = framing.read(&mut reader) => msg,
|
||||
msg = framing.read(&mut reader, &mut noise) => msg,
|
||||
_ = inner.kill.cancelled() => break,
|
||||
};
|
||||
match msg {
|
||||
Ok(Some(body)) => dispatch(&inner, &handler, ¬if_tx, &body),
|
||||
Ok(Some(body)) => {
|
||||
seen_message.store(true, Ordering::Relaxed);
|
||||
dispatch(&inner, &handler, ¬if_tx, &body);
|
||||
}
|
||||
Ok(None) => break,
|
||||
Err(e) => {
|
||||
tracing::warn!("jsonrpc read failed: {e}");
|
||||
if let Some(f) = &on_noise {
|
||||
f(format!("invalid protocol output: {e}"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
inner.reader_done.cancel();
|
||||
inner.close_transport();
|
||||
if close_on_eof || inner.kill.is_cancelled() {
|
||||
inner.mark_closed(None);
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
//! Text a server process writes outside the protocol: stderr, and stray stdout
|
||||
//! lines (a launcher script's or the runtime's own messages) before a message.
|
||||
//!
|
||||
//! Such text is often not UTF-8: on Windows, `cmd.exe`, batch files and native
|
||||
//! launchers write in the system code page (GBK on a Chinese system).
|
||||
|
||||
use encoding_rs::Encoding;
|
||||
use tokio::io::{AsyncBufReadExt, AsyncRead, BufReader};
|
||||
|
||||
/// `bytes` as text: UTF-8 when valid, else (on Windows) the console / ANSI code
|
||||
/// page, else UTF-8 with replacement characters.
|
||||
pub fn decode(bytes: &[u8]) -> String {
|
||||
decode_with(bytes, &native_code_pages())
|
||||
}
|
||||
|
||||
/// [`decode`] trying the given Windows code pages, in order, after UTF-8.
|
||||
pub fn decode_with(bytes: &[u8], code_pages: &[u32]) -> String {
|
||||
if let Ok(s) = std::str::from_utf8(bytes) {
|
||||
return s.to_owned();
|
||||
}
|
||||
for enc in code_pages.iter().filter_map(|&cp| encoding_for_code_page(cp)) {
|
||||
let (text, had_errors) = enc.decode_without_bom_handling(bytes);
|
||||
if !had_errors {
|
||||
return text.into_owned();
|
||||
}
|
||||
}
|
||||
String::from_utf8_lossy(bytes).into_owned()
|
||||
}
|
||||
|
||||
/// The `encoding_rs` encoding of a Windows code page, when it has one.
|
||||
pub fn encoding_for_code_page(cp: u32) -> Option<&'static Encoding> {
|
||||
Some(match cp {
|
||||
65001 => encoding_rs::UTF_8,
|
||||
936 => encoding_rs::GBK,
|
||||
54936 => encoding_rs::GB18030,
|
||||
950 => encoding_rs::BIG5,
|
||||
932 => encoding_rs::SHIFT_JIS,
|
||||
949 => encoding_rs::EUC_KR,
|
||||
866 => encoding_rs::IBM866,
|
||||
874 => encoding_rs::WINDOWS_874,
|
||||
1250 => encoding_rs::WINDOWS_1250,
|
||||
1251 => encoding_rs::WINDOWS_1251,
|
||||
1252 => encoding_rs::WINDOWS_1252,
|
||||
1253 => encoding_rs::WINDOWS_1253,
|
||||
1254 => encoding_rs::WINDOWS_1254,
|
||||
1255 => encoding_rs::WINDOWS_1255,
|
||||
1256 => encoding_rs::WINDOWS_1256,
|
||||
1257 => encoding_rs::WINDOWS_1257,
|
||||
1258 => encoding_rs::WINDOWS_1258,
|
||||
20866 => encoding_rs::KOI8_R,
|
||||
21866 => encoding_rs::KOI8_U,
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
|
||||
/// The OEM (console) and ANSI code pages: console programs and batch files write in
|
||||
/// the former, GUI-subsystem and Java launchers in the latter.
|
||||
#[cfg(windows)]
|
||||
fn native_code_pages() -> [u32; 2] {
|
||||
#[link(name = "kernel32")]
|
||||
unsafe extern "system" {
|
||||
fn GetOEMCP() -> u32;
|
||||
fn GetACP() -> u32;
|
||||
}
|
||||
// SAFETY: argument-less Win32 queries.
|
||||
unsafe { [GetOEMCP(), GetACP()] }
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
fn native_code_pages() -> [u32; 0] {
|
||||
[]
|
||||
}
|
||||
|
||||
/// Removes a trailing `\n` / `\r\n` (and stray `\r`s before it).
|
||||
pub fn trim_line_end(line: &[u8]) -> &[u8] {
|
||||
let mut end = line.len();
|
||||
while end > 0 && matches!(line[end - 1], b'\n' | b'\r') {
|
||||
end -= 1;
|
||||
}
|
||||
&line[..end]
|
||||
}
|
||||
|
||||
/// Reads `stream` to its end, calling `on_line` with each line decoded by [`decode`].
|
||||
/// Unlike `AsyncBufReadExt::lines`, a line that is not UTF-8 does not end the stream.
|
||||
pub async fn read_lines<R: AsyncRead + Unpin>(stream: R, mut on_line: impl FnMut(String)) {
|
||||
let mut reader = BufReader::new(stream);
|
||||
let mut line = Vec::new();
|
||||
loop {
|
||||
line.clear();
|
||||
match reader.read_until(b'\n', &mut line).await {
|
||||
Ok(0) | Err(_) => break,
|
||||
Ok(_) => on_line(decode(trim_line_end(&line))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// `请按任意键继续. . .`, what `pause` prints on a Chinese Windows (code page 936).
|
||||
const PAUSE_GBK: &[u8] = b"\xc7\xeb\xb0\xb4\xc8\xce\xd2\xe2\xbc\xfc\xbc\xcc\xd0\xf8. . .";
|
||||
|
||||
#[test]
|
||||
fn utf8_passes_through() {
|
||||
assert_eq!(decode_with("héllo 中文".as_bytes(), &[936]), "héllo 中文");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn code_page_text_is_decoded() {
|
||||
assert_eq!(decode_with(PAUSE_GBK, &[936, 936]), "请按任意键继续. . .");
|
||||
// The first code page that decodes cleanly wins.
|
||||
assert_eq!(decode_with(PAUSE_GBK, &[437, 936]), "请按任意键继续. . .");
|
||||
assert_eq!(decode_with(b"caf\xe9", &[1252]), "café");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn undecodable_text_is_lossy_utf8() {
|
||||
let out = decode_with(PAUSE_GBK, &[]);
|
||||
assert!(out.contains('\u{FFFD}') && out.ends_with(". . ."), "{out}");
|
||||
assert_eq!(decode_with(b"a\xffb", &[65001]), "a\u{FFFD}b");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn read_lines_survives_non_utf8_lines() {
|
||||
let mut input = b"first\r\n".to_vec();
|
||||
input.extend_from_slice(b"\xff\xfe broken\n");
|
||||
input.extend_from_slice(b"last");
|
||||
let mut lines = Vec::new();
|
||||
read_lines(&input[..], |l| lines.push(l)).await;
|
||||
assert_eq!(lines.len(), 3);
|
||||
assert_eq!(lines[0], "first");
|
||||
assert!(lines[1].ends_with(" broken"));
|
||||
assert_eq!(lines[2], "last");
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,46 @@ mod framing_tests {
|
||||
assert!(read_all(long.as_bytes()).await.is_err(), "header too long");
|
||||
}
|
||||
|
||||
async fn read_with_noise(input: &[u8]) -> (std::io::Result<Vec<Vec<u8>>>, Vec<String>) {
|
||||
let mut reader = BufReader::new(input);
|
||||
let mut noise = Vec::new();
|
||||
let mut out = Vec::new();
|
||||
let result = loop {
|
||||
match read_message_or_noise(&mut reader, &mut |l| noise.push(crate::output::decode(l))).await {
|
||||
Ok(Some(msg)) => out.push(msg),
|
||||
Ok(None) => break Ok(out),
|
||||
Err(e) => break Err(e),
|
||||
}
|
||||
};
|
||||
(result, noise)
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn output_between_messages_is_reported_and_skipped() {
|
||||
let input = b"OpenJDK 64-Bit Server VM warning: Sharing is only supported\r\n\xc7\xeb\xb0\xb4 \xff\n\
|
||||
Content-Length: 2\r\n\r\n{}Picked up JAVA_TOOL_OPTIONS: -Dx\nContent-Length: 4\r\n\r\nnull";
|
||||
let (msgs, noise) = read_with_noise(input).await;
|
||||
assert_eq!(msgs.unwrap(), vec![b"{}".to_vec(), b"null".to_vec()]);
|
||||
assert_eq!(noise.len(), 3, "{noise:?}");
|
||||
assert_eq!(noise[0], "OpenJDK 64-Bit Server VM warning: Sharing is only supported");
|
||||
assert_eq!(noise[2], "Picked up JAVA_TOOL_OPTIONS: -Dx");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn unterminated_output_then_eof_is_reported() {
|
||||
// `pause` prints its prompt without a newline and the process is gone.
|
||||
let (msgs, noise) = read_with_noise(b"Press any key to continue . . . ").await;
|
||||
assert!(msgs.unwrap().is_empty());
|
||||
assert_eq!(noise, ["Press any key to continue . . . "]);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn garbage_inside_a_header_is_still_an_error() {
|
||||
let (msgs, _) = read_with_noise(b"Content-Length: 2\r\nnot a header\r\n\r\n{}").await;
|
||||
let e = msgs.unwrap_err();
|
||||
assert!(e.to_string().contains("not a header"), "{e}");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn handles_partial_reads() {
|
||||
let (mut client, server) = tokio::io::duplex(4);
|
||||
@@ -351,3 +391,30 @@ async fn kill_terminates_process() {
|
||||
peer.kill();
|
||||
tokio::time::timeout(Duration::from_secs(5), peer.closed()).await.unwrap();
|
||||
}
|
||||
|
||||
/// A launcher that prints in the system code page and exits before speaking the
|
||||
/// protocol: `jdtls.bat` on a Chinese Windows when its Python step fails, then
|
||||
/// `pause` prints `请按任意键继续. . .` in GBK on stdout.
|
||||
#[cfg(unix)]
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn output_before_the_handshake_is_reported_not_dropped() {
|
||||
let lines = Arc::new(Mutex::new(Vec::new()));
|
||||
let sink = lines.clone();
|
||||
let script = r"printf 'python: not found\n' >&2; printf '\307\353\260\264\310\316\322\342\274\374\274\314\320\370. . .\r\n'; exit 1";
|
||||
let peer = Peer::spawn(
|
||||
"sh",
|
||||
&["-c".into(), script.into()],
|
||||
&std::env::temp_dir(),
|
||||
&[],
|
||||
Arc::new(NoopHandler),
|
||||
Box::new(move |l| sink.lock().push(l)),
|
||||
)
|
||||
.unwrap();
|
||||
let init = peer.request::<_, Value>("initialize", json!({}), None).await;
|
||||
assert!(matches!(init, Err(RpcError::Closed)), "{init:?}");
|
||||
assert_eq!(tokio::time::timeout(Duration::from_secs(5), peer.closed()).await.unwrap(), Some(1));
|
||||
// Everything the process wrote is in by the time the close is reported.
|
||||
let lines = lines.lock().clone();
|
||||
assert!(lines.iter().any(|l| l == "python: not found"), "{lines:?}");
|
||||
assert!(lines.iter().any(|l| l.ends_with(". . .") && l.len() > 6), "{lines:?}");
|
||||
}
|
||||
@@ -406,6 +406,10 @@ impl LspManager {
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::warn!("{}: initialize failed: {e}", server.name);
|
||||
if matches!(e, RpcError::Closed) {
|
||||
// The server is exiting: let it, so the crash report has its exit code and last output.
|
||||
let _ = tokio::time::timeout(Duration::from_secs(3), peer.closed()).await;
|
||||
}
|
||||
peer.kill();
|
||||
// Treated like a crash so transient failures retry with backoff.
|
||||
self.spawn_supervisor(server, generation, peer);
|
||||
|
||||
@@ -14,7 +14,7 @@ use std::net::{SocketAddr, TcpStream, ToSocketAddrs};
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
use std::time::{Duration, Instant};
|
||||
use tokio::io::{AsyncBufReadExt, AsyncRead, BufReader};
|
||||
use tokio::io::AsyncRead;
|
||||
|
||||
pub(crate) const PORT_PLACEHOLDER: &str = "${port}";
|
||||
pub(crate) const ROOT_PLACEHOLDER: &str = "${root}";
|
||||
@@ -157,12 +157,7 @@ pub(crate) fn connect_or_start(
|
||||
}
|
||||
|
||||
fn pump_lines<R: AsyncRead + Unpin + Send + 'static>(stream: R, on_line: Arc<dyn Fn(String) + Send + Sync>) {
|
||||
tokio::spawn(async move {
|
||||
let mut lines = BufReader::new(stream).lines();
|
||||
while let Ok(Some(line)) = lines.next_line().await {
|
||||
on_line(line);
|
||||
}
|
||||
});
|
||||
tokio::spawn(ide_jsonrpc::output::read_lines(stream, move |line| on_line(line)));
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
//! A stdio server that dies before the handshake: what it printed (on stderr, and
|
||||
//! on stdout outside the protocol, in any encoding) must reach the crash message.
|
||||
#![cfg(unix)]
|
||||
|
||||
use ide_core::event::ServerStatus;
|
||||
use ide_core::{DocId, IdeEvent, LanguageId};
|
||||
use ide_language::{LanguageConfig, LanguageRegistry, LanguageServerConfig};
|
||||
use ide_lsp::{LspManager, ProcessLauncher};
|
||||
use parking_lot::Mutex;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
/// Shaped like `jdtls.bat` on a Chinese Windows whose Python step fails: an error on
|
||||
/// stderr, then `pause` prompting in GBK on stdout (`请按任意键继续. . .`), reading one
|
||||
/// key from stdin, exiting with an error.
|
||||
const LAUNCHER: &str = r#"#!/bin/sh
|
||||
echo "'python' is not recognized as an internal or external command" >&2
|
||||
printf '\307\353\260\264\310\316\322\342\274\374\274\314\320\370. . . '
|
||||
head -c 1 >/dev/null
|
||||
printf '\r\n'
|
||||
exit 1
|
||||
"#;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn crash_before_the_handshake_reports_what_the_server_printed() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let root = dir.path().to_path_buf();
|
||||
let script = root.join("fake-jdtls");
|
||||
std::fs::write(&script, LAUNCHER).unwrap();
|
||||
std::fs::set_permissions(&script, std::os::unix::fs::PermissionsExt::from_mode(0o755)).unwrap();
|
||||
|
||||
let server: LanguageServerConfig =
|
||||
toml::from_str(&format!("name = \"fake\"\ncommand = {:?}", script.to_string_lossy())).unwrap();
|
||||
let lang: LanguageConfig = toml::from_str("id = \"java\"\nname = \"Java\"\nextensions = [\"java\"]").unwrap();
|
||||
let lang = LanguageConfig { language_servers: vec![server], ..lang };
|
||||
let registry = Arc::new(LanguageRegistry::from_configs(vec![lang]));
|
||||
let events = Arc::new(Mutex::new(Vec::new()));
|
||||
let sink = {
|
||||
let events = events.clone();
|
||||
Arc::new(move |e: IdeEvent| events.lock().push(e))
|
||||
};
|
||||
let mgr = LspManager::with_launcher(root.clone(), registry, sink, Arc::new(ProcessLauncher));
|
||||
let path = root.join("A.java");
|
||||
std::fs::write(&path, "class A {}\n").unwrap();
|
||||
mgr.did_open(DocId::next(), &path, &LanguageId::new("java"), 1, "class A {}\n");
|
||||
|
||||
let crashed = || {
|
||||
events.lock().iter().find_map(|e| match e {
|
||||
IdeEvent::LanguageServer { status: ServerStatus::Crashed, message, .. } => message.clone(),
|
||||
_ => None,
|
||||
})
|
||||
};
|
||||
let mut message = None;
|
||||
for _ in 0..1000 {
|
||||
message = crashed();
|
||||
if message.is_some() {
|
||||
break;
|
||||
}
|
||||
tokio::time::sleep(Duration::from_millis(10)).await;
|
||||
}
|
||||
let message = message.expect("the server is reported as crashed");
|
||||
assert!(message.starts_with("fake exited with code 1:\n"), "{message}");
|
||||
assert!(message.contains("'python' is not recognized"), "{message}");
|
||||
// The stdout prompt, decoded (code page 936 on Windows, lossily elsewhere).
|
||||
assert!(message.contains(". . ."), "{message}");
|
||||
mgr.shutdown_all().await;
|
||||
}
|
||||
@@ -22,6 +22,33 @@ fn sample(name: &str) -> PathBuf {
|
||||
repo().join("plugins").join(name)
|
||||
}
|
||||
|
||||
fn theme_template() -> PathBuf {
|
||||
repo().join("templates/theme-plugin")
|
||||
}
|
||||
|
||||
/// A theme package with a light and a dark theme, plus licence files, in `dir`.
|
||||
fn write_theme_pair(dir: &Path) {
|
||||
std::fs::create_dir_all(dir.join("t")).unwrap();
|
||||
std::fs::write(
|
||||
dir.join("plugin.toml"),
|
||||
"id = \"theme-pair\"\nname = \"Pair\"\nversion = \"1.0.0\"\nopenidea-api = \"0.1\"\n\
|
||||
[[contributes.themes]]\npath = \"t/day.json\"\n[[contributes.themes]]\npath = \"t/night.json\"\n",
|
||||
)
|
||||
.unwrap();
|
||||
std::fs::write(
|
||||
dir.join("t/day.json"),
|
||||
r##"{"id":"day","name":"Day","kind":"light","tokens":{"--bg-frame":"#eeeeee"}}"##,
|
||||
)
|
||||
.unwrap();
|
||||
std::fs::write(
|
||||
dir.join("t/night.json"),
|
||||
r##"{"id":"night","name":"Night","kind":"dark","tokens":{"--bg-frame":"#111111"}}"##,
|
||||
)
|
||||
.unwrap();
|
||||
std::fs::write(dir.join("LICENSE"), "MIT License\n").unwrap();
|
||||
std::fs::write(dir.join("NOTICE"), "Palette notice\n").unwrap();
|
||||
}
|
||||
|
||||
fn misbehave_pkg() -> PathBuf {
|
||||
Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/misbehave")
|
||||
}
|
||||
@@ -217,11 +244,11 @@ fn runtime_language_and_theme_registration() {
|
||||
#[test]
|
||||
fn contribution_only_plugins() {
|
||||
let f = fixture(Limits::default());
|
||||
let theme = f.host.install_from_dir(&sample("theme-solarized")).unwrap();
|
||||
let theme = f.host.install_from_dir(&theme_template()).unwrap();
|
||||
assert_eq!(theme.status, PluginStatus::Static);
|
||||
assert!(!theme.has_code);
|
||||
let ids: Vec<&str> = theme.themes.iter().map(|t| t.id.as_str()).collect();
|
||||
assert_eq!(ids, ["solarized-light", "solarized-dark"]);
|
||||
assert_eq!(ids, ["harbor-night"]);
|
||||
let lang = f.host.install_from_dir(&sample("language-toy")).unwrap();
|
||||
assert_eq!(lang.status, PluginStatus::Static);
|
||||
assert_eq!(lang.languages[0].id, "toy");
|
||||
@@ -229,14 +256,14 @@ fn contribution_only_plugins() {
|
||||
assert!(f.run("language-toy", "x", None).unwrap_err().contains("no code"));
|
||||
|
||||
f.take_events();
|
||||
let active = f.host.set_theme(Some(("theme-solarized", "solarized-dark"))).unwrap().unwrap();
|
||||
assert_eq!(active.theme.tokens["--bg-app"], "#002b36");
|
||||
assert_eq!(active.theme.tokens["--syn-string"], "#2aa198");
|
||||
let active = f.host.set_theme(Some(("theme-harbor-night", "harbor-night"))).unwrap().unwrap();
|
||||
assert_eq!(active.theme.tokens["--bg-app"], "#14171c");
|
||||
assert_eq!(active.theme.tokens["--syn-string"], "#9ccc7a");
|
||||
assert!(f.take_events().iter().any(|(_, e)| matches!(e, PluginEvent::ThemeChanged { theme: Some(_) })));
|
||||
assert_eq!(f.host.list(None).active_theme, Some(active));
|
||||
|
||||
// Disabling the plugin withdraws its theme and language.
|
||||
f.host.set_enabled("theme-solarized", false).unwrap();
|
||||
f.host.set_enabled("theme-harbor-night", false).unwrap();
|
||||
assert!(f.host.active_theme().is_none());
|
||||
assert!(f.take_events().iter().any(|(_, e)| *e == PluginEvent::ThemeChanged { theme: None }));
|
||||
f.host.set_enabled("language-toy", false).unwrap();
|
||||
@@ -247,7 +274,7 @@ fn contribution_only_plugins() {
|
||||
#[test]
|
||||
fn theme_template_installs_with_its_editor_scheme() {
|
||||
let f = fixture(Limits::default());
|
||||
let info = f.host.install_from_dir(&repo().join("templates/theme-plugin")).unwrap();
|
||||
let info = f.host.install_from_dir(&theme_template()).unwrap();
|
||||
assert_eq!(info.status, PluginStatus::Static);
|
||||
assert!(!info.has_code);
|
||||
assert_eq!(info.themes[0].id, "harbor-night");
|
||||
@@ -263,44 +290,42 @@ fn theme_template_installs_with_its_editor_scheme() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bundled_theme_plugins_install_with_their_licence() {
|
||||
fn theme_packages_install_with_their_licence() {
|
||||
let f = fixture(Limits::default());
|
||||
for (pkg, themes) in
|
||||
[("theme-solarized", ["solarized-light", "solarized-dark"]), ("theme-one", ["one-light", "one-dark"])]
|
||||
{
|
||||
let info = f.host.install_from_dir(&sample(pkg)).unwrap();
|
||||
assert_eq!(info.status, PluginStatus::Static, "{pkg}: {:?}", info.error);
|
||||
assert!(info.authors.iter().any(|a| a.starts_with("bghtyu")));
|
||||
let license = std::fs::read_to_string(f.plugins_dir.join(pkg).join("LICENSE")).unwrap();
|
||||
assert!(license.contains("MIT License"));
|
||||
for (theme, kind) in themes.iter().zip([ThemeKind::Light, ThemeKind::Dark]) {
|
||||
let active = f.host.set_theme(Some((pkg, theme))).unwrap().unwrap();
|
||||
assert_eq!(active.theme.kind, kind);
|
||||
let tokens = &active.theme.tokens;
|
||||
assert!(["--bg-frame", "--syn-keyword", "--ansi-red"].iter().all(|t| tokens.contains_key(*t)));
|
||||
}
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
write_theme_pair(dir.path());
|
||||
let info = f.host.install_from_dir(dir.path()).unwrap();
|
||||
assert_eq!(info.status, PluginStatus::Static, "{:?}", info.error);
|
||||
let installed = f.plugins_dir.join("theme-pair");
|
||||
assert!(std::fs::read_to_string(installed.join("LICENSE")).unwrap().contains("MIT License"));
|
||||
assert!(installed.join("NOTICE").is_file());
|
||||
for (theme, kind) in [("day", ThemeKind::Light), ("night", ThemeKind::Dark)] {
|
||||
let active = f.host.set_theme(Some(("theme-pair", theme))).unwrap().unwrap();
|
||||
assert_eq!(active.theme.kind, kind);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn theme_frame_follows_the_selection() {
|
||||
let f = fixture(Limits::default());
|
||||
f.host.install_from_dir(&sample("theme-one")).unwrap();
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
write_theme_pair(dir.path());
|
||||
f.host.install_from_dir(dir.path()).unwrap();
|
||||
// Nothing to attach it to without a selected theme.
|
||||
f.host.set_theme_frame(Some("#21252b")).unwrap();
|
||||
f.host.set_theme_frame(Some("#111111")).unwrap();
|
||||
assert_eq!(f.host.startup_frame(), None);
|
||||
f.host.set_theme(Some(("theme-one", "one-dark"))).unwrap();
|
||||
f.host.set_theme(Some(("theme-pair", "night"))).unwrap();
|
||||
assert!(f.host.set_theme_frame(Some("hsl(220, 13%, 15%)")).is_err());
|
||||
f.host.set_theme_frame(Some("#21252b")).unwrap();
|
||||
assert_eq!(f.host.startup_frame().as_deref(), Some("#21252b"));
|
||||
f.host.set_enabled("theme-one", false).unwrap();
|
||||
f.host.set_theme_frame(Some("#111111")).unwrap();
|
||||
assert_eq!(f.host.startup_frame().as_deref(), Some("#111111"));
|
||||
f.host.set_enabled("theme-pair", false).unwrap();
|
||||
assert_eq!(f.host.startup_frame(), None);
|
||||
f.host.set_enabled("theme-one", true).unwrap();
|
||||
assert_eq!(f.host.startup_frame().as_deref(), Some("#21252b"));
|
||||
f.host.set_enabled("theme-pair", true).unwrap();
|
||||
assert_eq!(f.host.startup_frame().as_deref(), Some("#111111"));
|
||||
// A new selection drops the old theme's colour until the UI reports the new one.
|
||||
f.host.set_theme(Some(("theme-one", "one-light"))).unwrap();
|
||||
f.host.set_theme(Some(("theme-pair", "day"))).unwrap();
|
||||
assert_eq!(f.host.startup_frame(), None);
|
||||
f.host.set_theme_frame(Some("#eaeaeb")).unwrap();
|
||||
f.host.set_theme_frame(Some("#eeeeee")).unwrap();
|
||||
f.host.set_theme(None).unwrap();
|
||||
assert_eq!(f.host.startup_frame(), None);
|
||||
}
|
||||
@@ -327,14 +352,14 @@ fn theme_with_broken_editor_scheme_fails_to_load() {
|
||||
fn state_persists_across_restarts() {
|
||||
let f = fixture(Limits::default());
|
||||
f.host.install_from_dir(&sample("hello")).unwrap();
|
||||
f.host.install_from_dir(&sample("theme-solarized")).unwrap();
|
||||
f.host.install_from_dir(&theme_template()).unwrap();
|
||||
f.host.set_enabled("hello", false).unwrap();
|
||||
f.host.set_theme(Some(("theme-solarized", "solarized-dark"))).unwrap();
|
||||
f.host.set_theme_frame(Some("#073642")).unwrap();
|
||||
f.host.set_theme(Some(("theme-harbor-night", "harbor-night"))).unwrap();
|
||||
f.host.set_theme_frame(Some("#1f252e")).unwrap();
|
||||
|
||||
let again = PluginHost::new(f.plugins_dir.clone(), Arc::new(|_: Option<&str>, _| {}), Limits::default()).unwrap();
|
||||
// Known before the plugins are loaded: new windows open in the theme's frame colour.
|
||||
assert_eq!(again.startup_frame().as_deref(), Some("#073642"));
|
||||
assert_eq!(again.startup_frame().as_deref(), Some("#1f252e"));
|
||||
assert!(!again.wait_initial_load(Duration::from_millis(1)));
|
||||
again.load_all();
|
||||
assert!(again.wait_initial_load(Duration::ZERO));
|
||||
@@ -342,7 +367,7 @@ fn state_persists_across_restarts() {
|
||||
let hello = list.plugins.iter().find(|p| p.id == "hello").unwrap();
|
||||
assert!(!hello.enabled);
|
||||
assert_eq!(hello.status, PluginStatus::Disabled);
|
||||
assert_eq!(list.active_theme.unwrap().theme.id, "solarized-dark");
|
||||
assert_eq!(list.active_theme.unwrap().theme.id, "harbor-night");
|
||||
assert!(
|
||||
again
|
||||
.run_command("hello", "insert-date", None, Invocation::default())
|
||||
@@ -436,16 +461,16 @@ fn catalog_lists_sample_packages() {
|
||||
std::fs::create_dir_all(tmp.path().join("junk")).unwrap();
|
||||
std::fs::write(tmp.path().join("junk/plugin.toml"), "garbage = ").unwrap();
|
||||
|
||||
let catalog = scan_catalog(&[repo().join("plugins"), tmp.path().to_path_buf()]);
|
||||
let catalog = scan_catalog(&[repo().join("plugins"), repo().join("templates"), tmp.path().to_path_buf()]);
|
||||
let ids: Vec<&str> = catalog.iter().map(|c| c.id.as_str()).collect();
|
||||
for id in ["hello", "theme-solarized", "theme-one", "language-toy", "x"] {
|
||||
for id in ["hello", "theme-harbor-night", "language-toy", "x"] {
|
||||
assert!(ids.contains(&id), "{id} missing from {ids:?}");
|
||||
}
|
||||
let hello = catalog.iter().find(|c| c.id == "hello").unwrap();
|
||||
assert!(hello.has_code && hello.problem.is_none() && hello.change_notes.is_some());
|
||||
assert_eq!(hello.commands.len(), 2);
|
||||
let theme = catalog.iter().find(|c| c.id == "theme-solarized").unwrap();
|
||||
assert_eq!((theme.theme_count, theme.has_code), (2, false));
|
||||
let theme = catalog.iter().find(|c| c.id == "theme-harbor-night").unwrap();
|
||||
assert_eq!((theme.theme_count, theme.has_code), (1, false));
|
||||
let x = catalog.iter().find(|c| c.id == "x").unwrap();
|
||||
assert!(x.problem.as_deref().unwrap().contains("plugin.wasm"));
|
||||
}
|
||||
@@ -0,0 +1,358 @@
|
||||
//! Starting jdtls on the JVM directly instead of through its launcher scripts.
|
||||
//!
|
||||
//! The release ships `bin/jdtls` (Python), `bin/jdtls.py` and, for Windows,
|
||||
//! `bin/jdtls.bat`, which runs `python` and then `pause`. Each needs a Python
|
||||
//! interpreter; without one the batch file prints `pause`'s prompt in the console
|
||||
//! code page and exits. The command line the script builds is reproduced here, so
|
||||
//! only a JDK is needed.
|
||||
|
||||
use crate::java::{Jdk, jdk_at};
|
||||
use ide_language::LanguageServerConfig;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
/// The parts of a jdtls install the JVM is started with.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct JdtlsInstall {
|
||||
/// `plugins/org.eclipse.equinox.launcher_<version>.jar`.
|
||||
pub launcher: PathBuf,
|
||||
/// The shared, read-only OSGi configuration for this platform (`config_win`, `config_mac_arm`…).
|
||||
pub config: PathBuf,
|
||||
}
|
||||
|
||||
/// Names of the release's launcher scripts; anything else is the user's own wrapper.
|
||||
const SCRIPTS: &[&str] = &["jdtls", "jdtls.bat", "jdtls.cmd", "jdtls.py"];
|
||||
|
||||
/// The directory with `plugins/` of the jdtls `executable` belongs to (`<home>/bin/jdtls`,
|
||||
/// or Homebrew's `<prefix>/bin/jdtls` wrapper with the install under `libexec`).
|
||||
pub fn jdtls_home(executable: &Path) -> Option<PathBuf> {
|
||||
let exe = dunce::canonicalize(executable).ok()?;
|
||||
let home = exe.parent()?.parent()?;
|
||||
[home.to_path_buf(), home.join("libexec")].into_iter().find(|h| h.join("plugins").is_dir())
|
||||
}
|
||||
|
||||
/// Shared configuration directories to try, best first, for `os` / `arch`
|
||||
/// (`std::env::consts` values), as the release names them.
|
||||
pub fn config_dir_names(os: &str, arch: &str) -> Vec<String> {
|
||||
let base = match os {
|
||||
"windows" => "config_win",
|
||||
"macos" => "config_mac",
|
||||
_ => "config_linux",
|
||||
};
|
||||
let mut names = Vec::new();
|
||||
if arch == "aarch64" {
|
||||
names.push(format!("{base}_arm"));
|
||||
}
|
||||
names.push(base.to_owned());
|
||||
names
|
||||
}
|
||||
|
||||
/// The launcher jar and configuration of the install at `home`, when it has the
|
||||
/// release layout.
|
||||
pub fn find_install(home: &Path, os: &str, arch: &str) -> Option<JdtlsInstall> {
|
||||
let plugins = home.join("plugins");
|
||||
let unversioned = plugins.join("org.eclipse.equinox.launcher.jar");
|
||||
let launcher = if unversioned.is_file() {
|
||||
unversioned
|
||||
} else {
|
||||
let mut jars: Vec<PathBuf> = std::fs::read_dir(&plugins)
|
||||
.ok()?
|
||||
.flatten()
|
||||
.map(|e| e.path())
|
||||
.filter(|p| {
|
||||
p.file_name().and_then(|n| n.to_str()).is_some_and(|n| {
|
||||
// Not the native fragments (`org.eclipse.equinox.launcher.win32.win32.x86_64_…`).
|
||||
n.starts_with("org.eclipse.equinox.launcher_") && n.ends_with(".jar")
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
jars.sort();
|
||||
jars.pop()?
|
||||
};
|
||||
let config =
|
||||
config_dir_names(os, arch).into_iter().map(|n| home.join(n)).find(|d| d.join("config.ini").is_file())?;
|
||||
Some(JdtlsInstall { launcher, config })
|
||||
}
|
||||
|
||||
/// Arguments meant for the launcher script, sorted out.
|
||||
#[derive(Debug, Default, PartialEq, Eq)]
|
||||
struct ScriptArgs {
|
||||
jvm: Vec<String>,
|
||||
java: Option<String>,
|
||||
data: Option<String>,
|
||||
rest: Vec<String>,
|
||||
}
|
||||
|
||||
fn split_script_args(args: &[String]) -> ScriptArgs {
|
||||
let mut out = ScriptArgs::default();
|
||||
let mut it = args.iter();
|
||||
while let Some(a) = it.next() {
|
||||
if let Some(v) = a.strip_prefix("--jvm-arg=") {
|
||||
out.jvm.push(v.to_owned());
|
||||
} else if a == "--jvm-arg" {
|
||||
out.jvm.extend(it.next().cloned());
|
||||
} else if let Some(v) = a.strip_prefix("--java-executable=") {
|
||||
out.java = Some(v.to_owned());
|
||||
} else if a == "--java-executable" {
|
||||
out.java = it.next().cloned();
|
||||
} else if a == "-data" {
|
||||
out.data = it.next().cloned();
|
||||
} else if let Some(v) = a.strip_prefix("-data=") {
|
||||
out.data = Some(v.to_owned());
|
||||
} else if a != "--validate-java-version" && a != "--no-validate-java-version" {
|
||||
out.rest.push(a.clone());
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// The JVM command line `bin/jdtls` builds: its system properties and module
|
||||
/// options, the user's `--jvm-arg`s, then the Equinox launcher with `-data`.
|
||||
pub fn java_args(install: &JdtlsInstall, java_major: u32, script_args: &[String]) -> Vec<String> {
|
||||
let parsed = split_script_args(script_args);
|
||||
let mut args: Vec<String> = Vec::new();
|
||||
if java_major >= 24 {
|
||||
args.extend(["-Djdk.xml.maxGeneralEntitySizeLimit=0".into(), "-Djdk.xml.totalEntitySizeLimit=0".into()]);
|
||||
}
|
||||
args.extend(
|
||||
[
|
||||
"-Declipse.application=org.eclipse.jdt.ls.core.id1",
|
||||
"-Dosgi.bundles.defaultStartLevel=4",
|
||||
"-Declipse.product=org.eclipse.jdt.ls.core.product",
|
||||
"-Dosgi.checkConfiguration=true",
|
||||
]
|
||||
.map(String::from),
|
||||
);
|
||||
args.push(format!("-Dosgi.sharedConfiguration.area={}", install.config.to_string_lossy()));
|
||||
args.extend(
|
||||
[
|
||||
"-Dosgi.sharedConfiguration.area.readOnly=true",
|
||||
"-Dosgi.configuration.cascaded=true",
|
||||
"-Xms1G",
|
||||
"--add-modules=ALL-SYSTEM",
|
||||
"--add-opens",
|
||||
"java.base/java.util=ALL-UNNAMED",
|
||||
"--add-opens",
|
||||
"java.base/java.lang=ALL-UNNAMED",
|
||||
]
|
||||
.map(String::from),
|
||||
);
|
||||
args.extend(parsed.jvm);
|
||||
args.extend(["-jar".to_owned(), install.launcher.to_string_lossy().into_owned()]);
|
||||
if let Some(data) = parsed.data {
|
||||
args.extend(["-data".to_owned(), data]);
|
||||
}
|
||||
args.extend(parsed.rest);
|
||||
args
|
||||
}
|
||||
|
||||
/// Rewrites a jdtls launch (`command` = the release's script, `JAVA_HOME` chosen by
|
||||
/// [`crate::java::configure_jdtls`]) to start `java` directly. Left unchanged when the
|
||||
/// command is someone's own wrapper, the install has another layout, or no JDK is set
|
||||
/// (the launch then reports why).
|
||||
pub fn launch_directly(cfg: &mut LanguageServerConfig) {
|
||||
if cfg.name != "jdtls" || cfg.launch_error.is_some() {
|
||||
return;
|
||||
}
|
||||
let search = cfg.env.get("PATH").map(std::ffi::OsString::from).or_else(|| std::env::var_os("PATH"));
|
||||
let Some(script) = search.and_then(|s| ide_run::which::find_executable(&cfg.command, &s)) else { return };
|
||||
let is_script = dunce::canonicalize(&script)
|
||||
.ok()
|
||||
.and_then(|p| p.file_name().map(|n| n.to_string_lossy().to_ascii_lowercase()))
|
||||
.is_some_and(|n| SCRIPTS.contains(&n.as_str()));
|
||||
if !is_script {
|
||||
return;
|
||||
}
|
||||
let Some(install) =
|
||||
jdtls_home(&script).and_then(|h| find_install(&h, std::env::consts::OS, std::env::consts::ARCH))
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let own_java = split_script_args(&cfg.args).java.map(PathBuf::from);
|
||||
let jdk: Option<(PathBuf, Jdk)> = match own_java {
|
||||
Some(java) => java.parent().and_then(Path::parent).and_then(jdk_at).map(|jdk| (java, jdk)),
|
||||
None => cfg.env.get("JAVA_HOME").and_then(|h| jdk_at(Path::new(h))).map(|jdk| {
|
||||
let java = crate::java::java_executable(&jdk.home);
|
||||
(java, jdk)
|
||||
}),
|
||||
};
|
||||
let Some((java, jdk)) = jdk.filter(|(java, _)| java.is_file()) else { return };
|
||||
cfg.args = java_args(&install, jdk.major, &cfg.args);
|
||||
cfg.command = java.to_string_lossy().into_owned();
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn strings(args: &[&str]) -> Vec<String> {
|
||||
args.iter().map(|s| s.to_string()).collect()
|
||||
}
|
||||
|
||||
/// What [`crate::java::configure_jdtls`] and the settings pass to the script.
|
||||
fn script_args(data: &str, agent: &str) -> Vec<String> {
|
||||
strings(&[
|
||||
"--jvm-arg=-Xmx2G",
|
||||
"-data",
|
||||
data,
|
||||
"--jvm-arg=-Djava.import.generatesMetadataFilesAtProjectRoot=false",
|
||||
&format!("--jvm-arg=-javaagent:{agent}"),
|
||||
])
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn windows_command_line() {
|
||||
// The reporter's layout: a managed install under %APPDATA%, JDK 25, a user name with a space and CJK.
|
||||
let tools = r"C:\Users\张 三\AppData\Roaming\ai.l0ng.openidea\tools\jdtls";
|
||||
let install = JdtlsInstall {
|
||||
launcher: PathBuf::from(format!(r"{tools}\plugins\org.eclipse.equinox.launcher_1.7.0.v20250424-1814.jar")),
|
||||
config: PathBuf::from(format!(r"{tools}\config_win")),
|
||||
};
|
||||
let data = r"C:\Users\张 三\AppData\Roaming\ai.l0ng.openidea\lsp\jdtls\0123456789abcdef";
|
||||
let agent = r"C:\Users\张 三\AppData\Roaming\ai.l0ng.openidea\tools\lombok\bin\lombok.jar";
|
||||
let args = java_args(&install, 25, &script_args(data, agent));
|
||||
assert_eq!(
|
||||
args,
|
||||
strings(&[
|
||||
"-Djdk.xml.maxGeneralEntitySizeLimit=0",
|
||||
"-Djdk.xml.totalEntitySizeLimit=0",
|
||||
"-Declipse.application=org.eclipse.jdt.ls.core.id1",
|
||||
"-Dosgi.bundles.defaultStartLevel=4",
|
||||
"-Declipse.product=org.eclipse.jdt.ls.core.product",
|
||||
"-Dosgi.checkConfiguration=true",
|
||||
&format!(r"-Dosgi.sharedConfiguration.area={tools}\config_win"),
|
||||
"-Dosgi.sharedConfiguration.area.readOnly=true",
|
||||
"-Dosgi.configuration.cascaded=true",
|
||||
"-Xms1G",
|
||||
"--add-modules=ALL-SYSTEM",
|
||||
"--add-opens",
|
||||
"java.base/java.util=ALL-UNNAMED",
|
||||
"--add-opens",
|
||||
"java.base/java.lang=ALL-UNNAMED",
|
||||
"-Xmx2G",
|
||||
"-Djava.import.generatesMetadataFilesAtProjectRoot=false",
|
||||
&format!("-javaagent:{agent}"),
|
||||
"-jar",
|
||||
&format!(r"{tools}\plugins\org.eclipse.equinox.launcher_1.7.0.v20250424-1814.jar"),
|
||||
"-data",
|
||||
data,
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unix_command_line() {
|
||||
let install = JdtlsInstall {
|
||||
launcher: PathBuf::from(
|
||||
"/Users/me/Library/Application Support/ai.l0ng.openidea/tools/jdtls/plugins/org.eclipse.equinox.launcher_1.7.0.jar",
|
||||
),
|
||||
config: PathBuf::from("/Users/me/Library/Application Support/ai.l0ng.openidea/tools/jdtls/config_mac_arm"),
|
||||
};
|
||||
let args = java_args(
|
||||
&install,
|
||||
21,
|
||||
&strings(&["--jvm-arg", "-Dlog.level=ALL", "--no-validate-java-version", "-data", "/d", "--extra"]),
|
||||
);
|
||||
assert_eq!(args[0], "-Declipse.application=org.eclipse.jdt.ls.core.id1", "no JDK 24+ flags on 21");
|
||||
assert!(args.contains(&"-Dosgi.sharedConfiguration.area=/Users/me/Library/Application Support/ai.l0ng.openidea/tools/jdtls/config_mac_arm".to_owned()));
|
||||
assert_eq!(
|
||||
args[args.len() - 7..],
|
||||
strings(&[
|
||||
"java.base/java.lang=ALL-UNNAMED",
|
||||
"-Dlog.level=ALL",
|
||||
"-jar",
|
||||
"/Users/me/Library/Application Support/ai.l0ng.openidea/tools/jdtls/plugins/org.eclipse.equinox.launcher_1.7.0.jar",
|
||||
"-data",
|
||||
"/d",
|
||||
"--extra",
|
||||
])
|
||||
);
|
||||
assert!(!args.iter().any(|a| a.contains("validate-java-version")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn config_dirs_per_platform() {
|
||||
assert_eq!(config_dir_names("windows", "x86_64"), ["config_win"]);
|
||||
assert_eq!(config_dir_names("windows", "aarch64"), ["config_win_arm", "config_win"]);
|
||||
assert_eq!(config_dir_names("macos", "aarch64"), ["config_mac_arm", "config_mac"]);
|
||||
assert_eq!(config_dir_names("linux", "x86_64"), ["config_linux"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn finds_the_launcher_and_configuration_of_a_release_layout() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let home = dir.path();
|
||||
std::fs::create_dir_all(home.join("plugins")).unwrap();
|
||||
for jar in [
|
||||
"org.eclipse.equinox.launcher_1.7.0.v20250424-1814.jar",
|
||||
"org.eclipse.equinox.launcher.win32.win32.x86_64_1.2.1300.v20250331-1702.jar",
|
||||
"org.eclipse.jdt.ls.core_1.50.0.jar",
|
||||
] {
|
||||
std::fs::write(home.join("plugins").join(jar), "").unwrap();
|
||||
}
|
||||
assert_eq!(find_install(home, "windows", "x86_64"), None, "no configuration");
|
||||
for config in ["config_win", "config_mac", "config_mac_arm"] {
|
||||
std::fs::create_dir_all(home.join(config)).unwrap();
|
||||
std::fs::write(home.join(config).join("config.ini"), "").unwrap();
|
||||
}
|
||||
let win = find_install(home, "windows", "x86_64").unwrap();
|
||||
assert_eq!(win.launcher, home.join("plugins/org.eclipse.equinox.launcher_1.7.0.v20250424-1814.jar"));
|
||||
assert_eq!(win.config, home.join("config_win"));
|
||||
assert_eq!(find_install(home, "windows", "aarch64").unwrap().config, home.join("config_win"));
|
||||
assert_eq!(find_install(home, "macos", "aarch64").unwrap().config, home.join("config_mac_arm"));
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn rewrites_the_release_script_to_java() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let home = dir.path().join("jdtls");
|
||||
std::fs::create_dir_all(home.join("bin")).unwrap();
|
||||
std::fs::create_dir_all(home.join("plugins")).unwrap();
|
||||
std::fs::write(home.join("plugins/org.eclipse.equinox.launcher_1.7.0.jar"), "").unwrap();
|
||||
for config in config_dir_names(std::env::consts::OS, std::env::consts::ARCH) {
|
||||
std::fs::create_dir_all(home.join(&config)).unwrap();
|
||||
std::fs::write(home.join(&config).join("config.ini"), "").unwrap();
|
||||
}
|
||||
let script = home.join("bin/jdtls");
|
||||
std::fs::write(&script, "#!/usr/bin/env python3\n").unwrap();
|
||||
std::fs::set_permissions(&script, std::os::unix::fs::PermissionsExt::from_mode(0o755)).unwrap();
|
||||
let jdk = dir.path().join("jdk-25");
|
||||
std::fs::create_dir_all(jdk.join("bin")).unwrap();
|
||||
std::fs::write(jdk.join("release"), "JAVA_VERSION=\"25.0.1\"\n").unwrap();
|
||||
std::fs::write(jdk.join("bin/java"), "").unwrap();
|
||||
|
||||
let cfg = |command: &str| -> LanguageServerConfig {
|
||||
let mut cfg: LanguageServerConfig =
|
||||
toml::from_str(&format!("name = \"jdtls\"\ncommand = {command:?}")).unwrap();
|
||||
cfg.env.insert("PATH".into(), home.join("bin").to_string_lossy().into_owned());
|
||||
cfg.env.insert("JAVA_HOME".into(), jdk.to_string_lossy().into_owned());
|
||||
cfg.args = strings(&["-data", "/ws", "--jvm-arg=-Xmx1G"]);
|
||||
cfg
|
||||
};
|
||||
let mut direct = cfg("jdtls");
|
||||
launch_directly(&mut direct);
|
||||
let java = dunce::canonicalize(&jdk).unwrap().join("bin/java");
|
||||
assert_eq!(Path::new(&direct.command), java);
|
||||
assert_eq!(direct.args[0], "-Djdk.xml.maxGeneralEntitySizeLimit=0");
|
||||
assert!(direct.args.iter().any(|a| a == "-Xmx1G"));
|
||||
let jar = direct.args.iter().position(|a| a == "-jar").unwrap();
|
||||
assert!(direct.args[jar + 1].ends_with("org.eclipse.equinox.launcher_1.7.0.jar"));
|
||||
assert_eq!(direct.args[jar + 2..], strings(&["-data", "/ws"]));
|
||||
|
||||
// Someone's own wrapper, or no usable JDK: the command is kept.
|
||||
std::fs::write(home.join("bin/my-jdtls"), "#!/bin/sh\n").unwrap();
|
||||
std::fs::set_permissions(home.join("bin/my-jdtls"), std::os::unix::fs::PermissionsExt::from_mode(0o755))
|
||||
.unwrap();
|
||||
let mut own = cfg("my-jdtls");
|
||||
launch_directly(&mut own);
|
||||
assert_eq!(own.command, "my-jdtls");
|
||||
let mut no_jdk = cfg("jdtls");
|
||||
no_jdk.env.remove("JAVA_HOME");
|
||||
launch_directly(&mut no_jdk);
|
||||
assert_eq!(no_jdk.command, "jdtls");
|
||||
let mut failing = cfg("jdtls");
|
||||
failing.launch_error = Some("needs JDK 25".into());
|
||||
launch_directly(&mut failing);
|
||||
assert_eq!(failing.command, "jdtls");
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ mod discover;
|
||||
mod exec;
|
||||
pub mod godot;
|
||||
pub mod java;
|
||||
pub mod jdtls;
|
||||
pub mod libraries;
|
||||
pub mod locate;
|
||||
pub mod lombok;
|
||||
|
||||
|
Після Ширина: | Висота: | Розмір: 169 KiB |
|
Після Ширина: | Висота: | Розмір: 133 KiB |
|
Після Ширина: | Висота: | Розмір: 171 KiB |
|
Після Ширина: | Висота: | Розмір: 135 KiB |
|
Після Ширина: | Висота: | Розмір: 164 KiB |
|
Після Ширина: | Висота: | Розмір: 129 KiB |
|
Після Ширина: | Висота: | Розмір: 168 KiB |
|
Після Ширина: | Висота: | Розмір: 131 KiB |
@@ -1,7 +1,8 @@
|
||||
# Theme plugins
|
||||
|
||||
OpenIDEA ships three built-in themes (Islands Light, Islands Dark, High
|
||||
Contrast). Everything else comes from **theme plugins**, the same model as
|
||||
OpenIDEA ships seven [built-in themes](../themes.md): Islands Light, Islands Dark,
|
||||
High Contrast, Solarized Light, Solarized Dark, One Light and One Dark. Additional
|
||||
themes come from **theme plugins**, the same model as
|
||||
IntelliJ IDEA, where most themes are plugins rather than part of the IDE.
|
||||
|
||||
A theme plugin is data only. Like an IntelliJ theme (a `.theme.json` plus an
|
||||
@@ -16,31 +17,6 @@ my-theme/
|
||||
└─ my-theme.scheme.json # editor colours, optional (IntelliJ: .icls)
|
||||
```
|
||||
|
||||
## Ready-made theme plugins
|
||||
|
||||
The repository's [`plugins/`](../../plugins) folder holds two complete theme
|
||||
plugins, each with a light and a dark theme and an editor colour scheme
|
||||
(syntax, editor and terminal ANSI colours):
|
||||
|
||||
| Package | Themes | Palette |
|
||||
|---|---|---|
|
||||
| [`plugins/theme-solarized`](../../plugins/theme-solarized) | Solarized Light, Solarized Dark | [Solarized](https://github.com/altercation/solarized) by Ethan Schoonover |
|
||||
| [`plugins/theme-one`](../../plugins/theme-one) | One Light, One Dark | Atom [One Light](https://github.com/atom/one-light-syntax) / [One Dark](https://github.com/atom/one-dark-syntax) by GitHub |
|
||||
|
||||
Both palettes are MIT-licensed; each package carries the notice in its
|
||||
`LICENSE`, which is installed with it. To use one:
|
||||
|
||||
1. *Settings › Plugins › ⚙ › Install Plugin from Disk…* and pick the package
|
||||
folder (`plugins/theme-solarized` or `plugins/theme-one` of a checkout or a
|
||||
downloaded copy). Development builds also list both on the *Available*
|
||||
tab, where *Install* does the same.
|
||||
2. Select the plugin and press *Apply* next to a theme.
|
||||
|
||||
The IDE remembers the theme: the next start-up opens its windows, splash and
|
||||
workbench in the theme's colours before the plugin host has loaded.
|
||||
|
||||
## Writing a theme plugin
|
||||
|
||||
The quickest way to start is to copy [`templates/theme-plugin`](../../templates/theme-plugin).
|
||||
It contains *Harbor Night*, a complete example dark theme that sets every
|
||||
themeable token. The rest of this page covers the file format, the token
|
||||
@@ -307,9 +283,8 @@ A `fontStyle: "italic"` on comments maps to `"--syn-comment-style": "italic"`.
|
||||
- Text should keep at least WCAG AA contrast (4.5:1) on its surfaces. The
|
||||
built-in themes are checked by `src/features/settings/__tests__/contrast.test.ts`.
|
||||
- Repository checks (for changes to this repo): `pnpm vitest run scripts/theme`
|
||||
validates the template and the theme plugins in `plugins/` against
|
||||
tokens.css and keeps this reference current, and `cargo test -p ide-plugin`
|
||||
loads them through the plugin host.
|
||||
validates the template against tokens.css and keeps this reference current,
|
||||
and `cargo test -p ide-plugin` loads the template through the plugin host.
|
||||
|
||||
## Token reference
|
||||
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
# Built-in theme sources
|
||||
|
||||
OpenIDEA includes Islands Light, Islands Dark, High Contrast, Solarized Light,
|
||||
Solarized Dark, One Light and One Dark. Select them in Settings › Appearance,
|
||||
Welcome › Customize or the existing quick theme menu. The same themes are
|
||||
available as explicit editor schemes; “Theme default” follows the UI theme.
|
||||
“Sync with OS” uses the existing preferred light/dark theme settings. Existing
|
||||
ids (`light`, `dark`, `dark-hc`, `system`) and attribute overrides remain valid.
|
||||
|
||||
## Upstream palettes and licenses
|
||||
|
||||
All sources below are the original authors’ repositories, pinned for reproducibility.
|
||||
Full MIT notices are preserved in [THIRD_PARTY_LICENSES.md](../THIRD_PARTY_LICENSES.md).
|
||||
|
||||
| Theme | Original source revision | Palette / mapping source |
|
||||
| ---------------------- | ------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
||||
| Solarized Light / Dark | [Ethan Schoonover, 62f656a](https://github.com/altercation/solarized/tree/62f656a02f93c5190a8753159e34b385588d5ff3) | README’s sixteen exact sRGB hex colours; `vim-colors-solarized/colors/solarized.vim` semantic roles; iTerm2 ANSI slots |
|
||||
| One Light syntax | [GitHub / Atom, d845790](https://github.com/atom/one-light-syntax/tree/d84579027410c576086dfca14d934c4bd74b0438) | `styles/colors.less`, `styles/syntax-variables.less` |
|
||||
| One Dark syntax | [GitHub / Atom, 9c96f44](https://github.com/atom/one-dark-syntax/tree/9c96f4454362267ac45322063e193ccf9d2debb1) | `styles/colors.less`, `styles/syntax-variables.less` |
|
||||
| One Light UI | [GitHub / Atom, a27bce3](https://github.com/atom/one-light-ui/tree/a27bce35088ecd323e44f5c2510bcf2d4e9efcf8) | `styles/ui-variables.less`, `styles/ui-variables-custom.less` |
|
||||
| One Dark UI | [GitHub / Atom, 18c2143](https://github.com/atom/one-dark-ui/tree/18c2143d41e17b337fff6dc7024562c4d999be17) | `styles/ui-variables.less`, `styles/ui-variables-custom.less` |
|
||||
|
||||
## Mapping into OpenIDEA
|
||||
|
||||
`src/platform/themes.ts` registers the stable ids. `data-theme` retains the
|
||||
light/dark kind for icons, native controls and existing selectors;
|
||||
`data-color-theme` selects the additional palette. High Contrast continues to
|
||||
use `data-contrast="high"`. Plugin themes clear the built-in palette attribute
|
||||
and retain their existing light/dark fallback; removing a plugin restores the
|
||||
chosen built-in palette.
|
||||
|
||||
`src/styles/tokens.css` contains the shared mapping for all colour tokens and
|
||||
four palette blocks. No new dependency is required. Solarized uses base3/base2
|
||||
for light backgrounds and base03/base02 for dark backgrounds, base00/base0 for
|
||||
text, and the original eight accents. Vim’s statements are green, constants
|
||||
and strings cyan, identifiers blue, types yellow, and comments the original
|
||||
subdued base1/base01. Solarized’s original ANSI slot order is preserved (the
|
||||
bright slots intentionally include orange, violet and neutrals).
|
||||
|
||||
One retains the exact HSL definitions from Atom, avoiding rounded palette
|
||||
approximations: 230° / 1% / 98% light and 220° / 13% / 18% dark editor backgrounds;
|
||||
purple keywords, green strings, blue functions, red variables/tags, orange
|
||||
numbers and attributes, yellow classes, and the original mono-3 comments.
|
||||
UI frame/popup levels use Atom’s relative background lightness formulas with
|
||||
the matching syntax theme. OpenIDEA’s shared UI text uses the syntax foreground
|
||||
and mono-2 for readable secondary labels. Selection and cursor-line values
|
||||
follow Atom’s syntax variables. Atom does not define a terminal ANSI palette:
|
||||
One’s ANSI slots reuse its exact semantic syntax hues, repeating them for bright
|
||||
colours rather than inventing a different palette. One Light maps ANSI white
|
||||
and bright white to its mono-2 and mono-1 text colours so they remain visible
|
||||
on the light terminal background.
|
||||
|
||||
Components without an upstream equivalent (feedback banners, tool window states,
|
||||
search fills and focus decoration) use the original semantic hues, neutrals,
|
||||
or explicit `color-mix()` tints. This adapts colours to the existing layout;
|
||||
it does not recreate Atom’s or Vim’s UI. Platform traffic-light colours stay
|
||||
platform colours. Original subdued comments and some syntax accents have lower
|
||||
contrast than a high-contrast accessibility theme; High Contrast remains available.
|
||||
|
||||
Native windows open in the theme's frame colour before their page loads:
|
||||
`src-tauri/src/theme_frame.rs` reads `--bg-frame` of each built-in theme from
|
||||
`tokens.css` itself (resolving `var()` and `hsl()`), so there is no second
|
||||
colour table to keep in sync. Elsewhere the frontend resolves HSL and
|
||||
`color-mix()` tokens to RGB (`src/platform/cssColor.ts`) for Tauri's window
|
||||
API, the native Settings window, Mermaid and the terminal.
|
||||
|
||||
`public/boot.js` restores the palette (`data-color-theme`) and the splash's
|
||||
resolved frame, text and accent colours before the application stylesheet
|
||||
loads, so a restart in One Dark or Solarized shows no flash of another theme.
|
||||
The backend's settings persistence remains authoritative. Terminal, Mermaid
|
||||
and editor-scheme observers also watch palette changes within the same
|
||||
light/dark kind. Custom accents, explicit editor schemes, per-scheme attribute
|
||||
overrides, compact mode and accessibility options retain their precedence.
|
||||
|
||||
`src/features/settings/__tests__/contrast.test.ts` requires every palette theme
|
||||
to define every colour token of the base themes (in the shared mapping or its
|
||||
own block), so a token added to `tokens.css` later can't silently fall back to
|
||||
an Islands colour.
|
||||
|
||||
## Browser evidence
|
||||
|
||||
These approved screenshots are reused from the original theme implementation on
|
||||
0.1.15; regression checks are rerun against the upstream contribution base.
|
||||
Captured at 1400 × 900 in Linux Chromium 154 using OpenIDEA's public in-memory
|
||||
`acme-api` project / Kotlin fixture and synthetic ANSI terminal output. The
|
||||
terminal is a real xterm renderer, without a native PTY or shell. These images
|
||||
cover the shell, sidebar, editor, gutter, find matches, terminal, Settings,
|
||||
focused controls, disabled settings and the selected theme popup.
|
||||
|
||||
| Theme | Workbench, editor and terminal | Settings and theme popup |
|
||||
|---|---|---|
|
||||
| Solarized Light | [Screenshot](media/themes/solarized-light-workbench.png) | [Screenshot](media/themes/solarized-light-popup.png) |
|
||||
| Solarized Dark | [Screenshot](media/themes/solarized-dark-workbench.png) | [Screenshot](media/themes/solarized-dark-popup.png) |
|
||||
| One Light | [Screenshot](media/themes/one-light-workbench.png) | [Screenshot](media/themes/one-light-popup.png) |
|
||||
| One Dark | [Screenshot](media/themes/one-dark-workbench.png) | [Screenshot](media/themes/one-dark-popup.png) |
|
||||
|
||||
The browser regression also checks refresh / startup cache restoration,
|
||||
selection visibility, same-kind switches, the quick menu, existing themes,
|
||||
explicit editor schemes and preferred OS themes. Native startup colours are
|
||||
covered by Rust unit tests.
|
||||
@@ -0,0 +1,188 @@
|
||||
import { expect, openFromTree, test } from "./fixtures";
|
||||
import type { Page } from "@playwright/test";
|
||||
|
||||
test.setTimeout(60_000);
|
||||
|
||||
const palettes = [
|
||||
{
|
||||
id: "solarized-light",
|
||||
label: "Solarized Light",
|
||||
kind: "light",
|
||||
bg: "rgb(253, 246, 227)",
|
||||
fg: "rgb(101, 123, 131)",
|
||||
frame: [238, 232, 213, 255],
|
||||
},
|
||||
{
|
||||
id: "solarized-dark",
|
||||
label: "Solarized Dark",
|
||||
kind: "dark",
|
||||
bg: "rgb(0, 43, 54)",
|
||||
fg: "rgb(131, 148, 150)",
|
||||
frame: [7, 54, 66, 255],
|
||||
},
|
||||
{
|
||||
id: "one-light",
|
||||
label: "One Light",
|
||||
kind: "light",
|
||||
bg: "rgb(250, 250, 250)",
|
||||
fg: "rgb(56, 58, 66)",
|
||||
frame: [234, 234, 235, 255],
|
||||
},
|
||||
{
|
||||
id: "one-dark",
|
||||
label: "One Dark",
|
||||
kind: "dark",
|
||||
bg: "rgb(40, 44, 52)",
|
||||
fg: "rgb(171, 178, 191)",
|
||||
frame: [33, 37, 43, 255],
|
||||
},
|
||||
];
|
||||
|
||||
async function choose(page: Page, control: string, label: string) {
|
||||
await page.getByRole("button", { name: control, exact: true }).click();
|
||||
await page.getByRole("option", { name: label, exact: true }).click();
|
||||
}
|
||||
async function settings(page: Page) {
|
||||
await page.keyboard.press("Meta+,");
|
||||
const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
|
||||
await expect(dialog).toBeVisible();
|
||||
await dialog
|
||||
.locator('[role="treeitem"][aria-level="2"]')
|
||||
.filter({ hasText: /^Appearance$/ })
|
||||
.click();
|
||||
return dialog;
|
||||
}
|
||||
|
||||
for (const palette of palettes) {
|
||||
test(`${palette.label}: settings, editor, terminal, popup and reload`, async ({ workbench: page }, info) => {
|
||||
const editor = await openFromTree(page, "build.gradle.kts");
|
||||
await page.keyboard.press("Alt+F12");
|
||||
await expect(page.locator(".xterm")).toBeVisible();
|
||||
// Use only synthetic ANSI output; no shell, network or native PTY is involved.
|
||||
await page.evaluate(async () => {
|
||||
const path = "/src/features/terminal/store.ts";
|
||||
const { activeSession } = await import(/* @vite-ignore */ path);
|
||||
const session = activeSession();
|
||||
session.term.clear();
|
||||
session.term.writeln("Synthetic theme regression — no PTY");
|
||||
session.term.writeln("\x1b[31merror\x1b[0m \x1b[33mwarning\x1b[0m \x1b[32msuccess\x1b[0m \x1b[34minfo\x1b[0m");
|
||||
});
|
||||
const dialog = await settings(page);
|
||||
await choose(page, "Theme", palette.label);
|
||||
await dialog.getByRole("button", { name: "Apply", exact: true }).click();
|
||||
await expect(page.locator("html")).toHaveAttribute("data-color-theme", palette.id);
|
||||
await expect(page.locator("html")).toHaveAttribute("data-theme", palette.kind);
|
||||
expect(
|
||||
await page.evaluate(async () => {
|
||||
const path = "/src/workbench/theme.ts";
|
||||
const { windowBackgroundColor, windowBackgroundHex } = await import(/* @vite-ignore */ path);
|
||||
return { rgba: windowBackgroundColor(), hex: windowBackgroundHex() };
|
||||
}),
|
||||
).toEqual({
|
||||
rgba: palette.frame,
|
||||
hex:
|
||||
"#" +
|
||||
palette.frame
|
||||
.slice(0, 3)
|
||||
.map((n) => n.toString(16).padStart(2, "0"))
|
||||
.join(""),
|
||||
});
|
||||
await page.screenshot({ path: info.outputPath(`${palette.id}-settings.png`), animations: "disabled" });
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(editor).toHaveCSS("background-color", palette.bg);
|
||||
await expect(editor).toHaveCSS("color", palette.fg);
|
||||
await expect(editor.locator(".cm-gutters")).toHaveCSS("background-color", palette.bg);
|
||||
await expect
|
||||
.poll(() =>
|
||||
page.evaluate(async () => {
|
||||
const path = "/src/features/terminal/store.ts";
|
||||
const { activeSession } = await import(/* @vite-ignore */ path);
|
||||
return activeSession().term.options.theme.background;
|
||||
}),
|
||||
)
|
||||
.toBe(
|
||||
palette.id === "solarized-light"
|
||||
? "#fdf6e3"
|
||||
: palette.id === "solarized-dark"
|
||||
? "#002b36"
|
||||
: palette.id === "one-light"
|
||||
? "#fafafa"
|
||||
: "#282c34",
|
||||
);
|
||||
await editor.locator(".cm-content").click();
|
||||
await page.keyboard.press("Meta+a");
|
||||
await expect(editor.locator(".cm-selectionBackground").first()).toBeVisible();
|
||||
await page.keyboard.press("ArrowRight");
|
||||
await page.keyboard.press("Meta+f");
|
||||
await page.getByRole("textbox", { name: "Find", exact: true }).fill("Order");
|
||||
await expect(editor.locator(".cm-openidea-findMatch").first()).toBeVisible();
|
||||
await page.screenshot({ path: info.outputPath(`${palette.id}-workbench.png`), animations: "disabled" });
|
||||
await page.keyboard.press("Escape");
|
||||
await settings(page);
|
||||
await page.getByRole("button", { name: "Theme", exact: true }).click();
|
||||
await expect(page.getByRole("listbox", { name: "Theme", exact: true })).toBeVisible();
|
||||
await page.screenshot({ path: info.outputPath(`${palette.id}-popup.png`), animations: "disabled" });
|
||||
await page.keyboard.press("Escape");
|
||||
await page.keyboard.press("Escape");
|
||||
await page.reload();
|
||||
await expect(page.getByRole("tree", { name: "Project" })).toBeVisible();
|
||||
await expect(page.locator("html")).toHaveAttribute("data-color-theme", palette.id);
|
||||
const cached = await page.evaluate(() => JSON.parse(localStorage.getItem("openidea.theme")!));
|
||||
expect(cached).toMatchObject({ theme: palette.kind, colorTheme: palette.id });
|
||||
});
|
||||
}
|
||||
|
||||
test("same-kind switching, legacy themes, system mode and explicit editor schemes", async ({ workbench: page }) => {
|
||||
await openFromTree(page, "build.gradle.kts");
|
||||
const dialog = await settings(page);
|
||||
for (const label of [
|
||||
"Solarized Light",
|
||||
"One Light",
|
||||
"Solarized Dark",
|
||||
"One Dark",
|
||||
"Islands Light",
|
||||
"Islands Dark",
|
||||
"High Contrast",
|
||||
]) {
|
||||
await choose(page, "Theme", label);
|
||||
await dialog.getByRole("button", { name: "Apply", exact: true }).click();
|
||||
if (label === "High Contrast") await expect(page.locator("html")).toHaveAttribute("data-contrast", "high");
|
||||
else await expect(page.locator("html")).not.toHaveAttribute("data-contrast");
|
||||
const added = palettes.find((p) => p.label === label);
|
||||
if (added) await expect(page.locator("html")).toHaveAttribute("data-color-theme", added.id);
|
||||
else await expect(page.locator("html")).not.toHaveAttribute("data-color-theme");
|
||||
const bg =
|
||||
added?.bg ??
|
||||
(label === "Islands Light"
|
||||
? "rgb(255, 255, 255)"
|
||||
: label === "Islands Dark"
|
||||
? "rgb(25, 26, 28)"
|
||||
: "rgb(0, 0, 0)");
|
||||
await expect(page.locator(".cm-editor").first()).toHaveCSS("background-color", bg);
|
||||
}
|
||||
await choose(page, "Theme", "One Light");
|
||||
await choose(page, "Editor color scheme", "Solarized Dark");
|
||||
await dialog.getByRole("button", { name: "Apply", exact: true }).click();
|
||||
await expect(page.locator(".cm-editor").first()).toHaveCSS("background-color", "rgb(0, 43, 54)");
|
||||
await choose(page, "Editor color scheme", "Theme default");
|
||||
await dialog.getByLabel("Sync with OS", { exact: true }).check();
|
||||
await dialog.getByRole("button", { name: "Preferred themes", exact: true }).click();
|
||||
await choose(page, "Preferred light theme", "Solarized Light");
|
||||
await choose(page, "Preferred dark theme", "One Dark");
|
||||
await page.keyboard.press("Escape");
|
||||
await dialog.getByRole("button", { name: "Apply", exact: true }).click();
|
||||
await page.emulateMedia({ colorScheme: "light" });
|
||||
await expect(page.locator("html")).toHaveAttribute("data-color-theme", "solarized-light");
|
||||
await page.emulateMedia({ colorScheme: "dark" });
|
||||
await expect(page.locator("html")).toHaveAttribute("data-color-theme", "one-dark");
|
||||
});
|
||||
|
||||
test("quick theme menu offers all four palettes and applies their kind", async ({ workbench: page }) => {
|
||||
for (const palette of palettes) {
|
||||
await page.getByRole("button", { name: "IDE and Project Settings", exact: true }).click();
|
||||
await page.getByText("Theme", { exact: true }).click();
|
||||
await page.getByText(palette.label, { exact: true }).click();
|
||||
await expect(page.locator("html")).toHaveAttribute("data-color-theme", palette.id);
|
||||
await expect(page.locator("html")).toHaveAttribute("data-theme", palette.kind);
|
||||
}
|
||||
});
|
||||
@@ -11,8 +11,6 @@ code at all.
|
||||
plugins/
|
||||
├─ build.sh # builds Rust plugins into components
|
||||
├─ hello/ # Rust plugin: two commands
|
||||
├─ theme-solarized/ # manifest-only: Solarized Light / Dark themes
|
||||
├─ theme-one/ # manifest-only: One Light / Dark themes
|
||||
└─ language-toy/ # manifest-only: a language definition
|
||||
```
|
||||
|
||||
@@ -171,10 +169,10 @@ never affected.
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "solarized-dark",
|
||||
"name": "Solarized Dark",
|
||||
"id": "harbor-night",
|
||||
"name": "Harbor Night",
|
||||
"kind": "dark",
|
||||
"tokens": { "--bg-app": "#002b36", "--accent": "#268bd2", "--syn-keyword": "#859900" }
|
||||
"tokens": { "--bg-app": "#14171c", "--accent": "#2b9e93", "--syn-keyword": "#e0a46e" }
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
The One Light and One Dark palettes are adapted from GitHub's Atom One themes
|
||||
(styles/colors.less, styles/syntax-variables.less, styles/ui-variables.less):
|
||||
|
||||
- https://github.com/atom/one-light-syntax (revision d84579027410c576086dfca14d934c4bd74b0438)
|
||||
- https://github.com/atom/one-dark-syntax (revision 9c96f4454362267ac45322063e193ccf9d2debb1)
|
||||
- https://github.com/atom/one-light-ui (revision a27bce35088ecd323e44f5c2510bcf2d4e9efcf8)
|
||||
- https://github.com/atom/one-dark-ui (revision 18c2143d41e17b337fff6dc7024562c4d999be17)
|
||||
|
||||
The exact HSL definitions are kept. Atom defines no terminal palette, so the
|
||||
ANSI slots reuse One's syntax hues. Adapted to OpenIDEA's design tokens by bghtyu.
|
||||
|
||||
## one-light-syntax, one-dark-syntax
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2016 GitHub Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
## one-light-ui, one-dark-ui
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2014 GitHub Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -1,17 +0,0 @@
|
||||
# Contribution-only theme plugin: no code, just theme and editor scheme files.
|
||||
id = "theme-one"
|
||||
name = "One Themes"
|
||||
version = "1.0.0"
|
||||
description = "One Light and One Dark: the Atom One palettes by GitHub for the UI, the editor and the terminal."
|
||||
authors = ["bghtyu <[email protected]>", "GitHub Inc. (Atom One palettes)"]
|
||||
homepage = "https://github.com/atom/one-dark-syntax"
|
||||
change-notes = "1.0.0 — One Light and One Dark: UI, editor colour scheme and terminal ANSI colours."
|
||||
openidea-api = "0.1"
|
||||
|
||||
[[contributes.themes]]
|
||||
path = "themes/one-light.theme.json"
|
||||
editor-scheme = "themes/one-light.scheme.json"
|
||||
|
||||
[[contributes.themes]]
|
||||
path = "themes/one-dark.theme.json"
|
||||
editor-scheme = "themes/one-dark.scheme.json"
|
||||
@@ -1,103 +0,0 @@
|
||||
// Atom One palette by GitHub Inc. (https://github.com/atom/one-dark-syntax and friends),
|
||||
// MIT licence, see LICENSE. Adapted to OpenIDEA's tokens by bghtyu.
|
||||
// Editor colour scheme: syntax, editor surfaces and terminal ANSI colours.
|
||||
{
|
||||
"name": "One Dark",
|
||||
"tokens": {
|
||||
// Syntax
|
||||
"--syn-keyword": "hsl(286, 60%, 67%)",
|
||||
"--syn-string": "hsl(95, 38%, 62%)",
|
||||
"--syn-type": "hsl(39, 67%, 69%)",
|
||||
"--syn-function": "hsl(207, 82%, 66%)",
|
||||
"--syn-function-call": "hsl(207, 82%, 66%)",
|
||||
"--syn-comment": "hsl(220, 10%, 40%)",
|
||||
"--syn-comment-style": "italic",
|
||||
"--syn-doc-comment": "hsl(220, 10%, 40%)",
|
||||
"--syn-docstring": "hsl(95, 38%, 62%)",
|
||||
"--syn-annotation": "hsl(29, 54%, 61%)",
|
||||
"--syn-decorator": "hsl(29, 54%, 61%)",
|
||||
"--syn-number": "hsl(29, 54%, 61%)",
|
||||
"--syn-punct": "hsl(220, 14%, 71%)",
|
||||
"--syn-variable": "hsl(355, 65%, 65%)",
|
||||
"--syn-param": "hsl(220, 14%, 71%)",
|
||||
"--syn-property": "hsl(220, 14%, 71%)",
|
||||
"--syn-constant": "hsl(29, 54%, 61%)",
|
||||
"--syn-builtin": "hsl(187, 47%, 55%)",
|
||||
"--syn-self": "hsl(355, 65%, 65%)",
|
||||
"--syn-keyword-arg": "hsl(355, 65%, 65%)",
|
||||
"--syn-predefined": "hsl(187, 47%, 55%)",
|
||||
"--syn-escape": "hsl(187, 47%, 55%)",
|
||||
"--syn-regexp": "hsl(187, 47%, 55%)",
|
||||
"--syn-tag": "hsl(355, 65%, 65%)",
|
||||
"--syn-attribute": "hsl(29, 54%, 61%)",
|
||||
"--syn-todo": "hsl(286, 60%, 67%)",
|
||||
"--syn-link": "hsl(207, 82%, 66%)",
|
||||
"--syn-markup-heading": "hsl(207, 82%, 66%)",
|
||||
"--syn-markup-code": "hsl(95, 38%, 62%)",
|
||||
"--syn-invalid": "hsl(355, 65%, 65%)",
|
||||
"--syn-inline-value": "hsl(220, 9%, 55%)",
|
||||
"--syn-rainbow-1": "hsl(187, 47%, 55%)",
|
||||
"--syn-rainbow-2": "hsl(29, 54%, 61%)",
|
||||
"--syn-rainbow-3": "hsl(95, 38%, 62%)",
|
||||
"--syn-rainbow-4": "hsl(286, 60%, 67%)",
|
||||
"--syn-rainbow-5": "hsl(207, 82%, 66%)",
|
||||
"--syn-bracket-1": "hsl(39, 67%, 69%)",
|
||||
"--syn-bracket-2": "hsl(286, 60%, 67%)",
|
||||
"--syn-bracket-3": "hsl(207, 82%, 66%)",
|
||||
|
||||
// Editor
|
||||
"--fg-editor": "hsl(220, 14%, 71%)",
|
||||
"--caret": "hsl(220, 100%, 66%)",
|
||||
"--fg-line-number": "hsl(220, 9%, 55%)",
|
||||
"--fg-line-number-current": "hsl(220, 14%, 71%)",
|
||||
"--border-gutter": "hsl(220, 13%, 10.8%)",
|
||||
"--border-indent-guide": "hsl(220, 13%, 10.8%)",
|
||||
"--border-indent-guide-active": "hsl(220, 100%, 66%)",
|
||||
"--border-right-margin": "hsl(220, 13%, 10.8%)",
|
||||
"--bg-editor-selection": "hsl(220, 13%, 28%)",
|
||||
"--bg-editor-selection-inactive": "hsl(220, 13%, 28%)",
|
||||
"--bg-text-search-result": "color-mix(in srgb, hsl(39, 67%, 69%) 22%, hsl(220, 13%, 18%))",
|
||||
"--bg-text-search-result-current": "color-mix(in srgb, hsl(39, 67%, 69%) 36%, hsl(220, 13%, 18%))",
|
||||
"--bg-matched-brace": "hsl(220, 13%, 28%)",
|
||||
"--matched-brace-weight": "var(--fw-code-bold)",
|
||||
"--bg-matched-tag": "hsl(220, 13%, 28%)",
|
||||
"--bg-fold-placeholder": "hsl(220, 13%, 15%)",
|
||||
"--fg-fold-placeholder": "hsl(220, 14%, 71%)",
|
||||
"--fg-fold-marker": "hsl(220, 9%, 55%)",
|
||||
"--fg-whitespace": "hsl(220, 9%, 55%)",
|
||||
"--fg-unused": "hsl(220, 9%, 55%)",
|
||||
"--bg-identifier-under-caret": "hsl(220, 13%, 28%)",
|
||||
"--bg-identifier-under-caret-write": "color-mix(in srgb, hsl(355, 65%, 65%) 12%, hsl(220, 13%, 18%))",
|
||||
"--fg-inlay": "hsl(220, 9%, 55%)",
|
||||
"--bg-inlay": "hsl(220, 13%, 15%)",
|
||||
"--wave-error": "hsl(355, 65%, 65%)",
|
||||
"--wave-warning": "hsl(39, 67%, 69%)",
|
||||
"--editor-error-decoration": "underline wavy var(--wave-error)",
|
||||
"--editor-warning-decoration": "underline wavy var(--wave-warning)",
|
||||
"--editor-warning-background": "color-mix(in srgb, hsl(39, 67%, 69%) 12%, hsl(220, 13%, 18%))",
|
||||
"--bg-breakpoint-line": "color-mix(in srgb, hsl(355, 65%, 65%) 12%, hsl(220, 13%, 18%))",
|
||||
"--fg-completion-match": "hsl(207, 82%, 66%)",
|
||||
"--bg-editor-inline": "hsl(220, 13%, 15%)",
|
||||
"--bg-editor-banner": "color-mix(in srgb, hsl(207, 82%, 66%) 12%, hsl(220, 13%, 18%))",
|
||||
"--fg-weak-warning": "hsl(220, 9%, 55%)",
|
||||
"--fg-bulb": "hsl(39, 67%, 69%)",
|
||||
|
||||
// ANSI palette
|
||||
"--ansi-black": "hsl(220, 13%, 15%)",
|
||||
"--ansi-red": "hsl(355, 65%, 65%)",
|
||||
"--ansi-green": "hsl(95, 38%, 62%)",
|
||||
"--ansi-yellow": "hsl(39, 67%, 69%)",
|
||||
"--ansi-blue": "hsl(207, 82%, 66%)",
|
||||
"--ansi-magenta": "hsl(286, 60%, 67%)",
|
||||
"--ansi-cyan": "hsl(187, 47%, 55%)",
|
||||
"--ansi-white": "hsl(220, 14%, 71%)",
|
||||
"--ansi-bright-black": "hsl(220, 9%, 55%)",
|
||||
"--ansi-bright-red": "hsl(355, 65%, 65%)",
|
||||
"--ansi-bright-green": "hsl(95, 38%, 62%)",
|
||||
"--ansi-bright-yellow": "hsl(39, 67%, 69%)",
|
||||
"--ansi-bright-blue": "hsl(207, 82%, 66%)",
|
||||
"--ansi-bright-magenta": "hsl(286, 60%, 67%)",
|
||||
"--ansi-bright-cyan": "hsl(187, 47%, 55%)",
|
||||
"--ansi-bright-white": "#ffffff"
|
||||
}
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
// Atom One palette by GitHub Inc. (https://github.com/atom/one-dark-syntax and friends),
|
||||
// MIT licence, see LICENSE. Adapted to OpenIDEA's tokens by bghtyu.
|
||||
// UI theme; the editor colour scheme is in one-dark.scheme.json.
|
||||
{
|
||||
"id": "one-dark",
|
||||
"name": "One Dark",
|
||||
"kind": "dark",
|
||||
"tokens": {
|
||||
// Surfaces
|
||||
"--bg-app": "hsl(220, 13%, 18%)",
|
||||
"--bg-elev": "hsl(220, 13%, 15%)",
|
||||
"--bg-popup": "hsl(220, 13%, 16.5%)",
|
||||
"--bg-hover": "hsl(220, 13%, 22%)",
|
||||
"--bg-selected": "hsl(220, 13%, 28%)",
|
||||
"--bg-selected-strong": "hsl(220, 13%, 28%)",
|
||||
"--bg-current-line": "color-mix(in srgb, hsl(220, 100%, 80%) 4%, hsl(220, 13%, 18%))",
|
||||
"--bg-debug-line": "color-mix(in srgb, hsl(207, 82%, 66%) 12%, hsl(220, 13%, 18%))",
|
||||
"--bg-backdrop": "hsl(220, 13%, 15%)",
|
||||
"--bg-input": "hsl(220, 13%, 18%)",
|
||||
|
||||
// Lines
|
||||
"--border": "hsl(220, 13%, 10.8%)",
|
||||
"--border-popup": "hsl(220, 13%, 10.8%)",
|
||||
"--border-strong": "hsl(220, 9%, 55%)",
|
||||
"--border-window": "hsl(220, 13%, 10.8%)",
|
||||
"--control-off": "hsl(220, 9%, 55%)",
|
||||
|
||||
// Text
|
||||
"--fg-strong": "hsl(220, 14%, 71%)",
|
||||
"--fg-emphasis": "hsl(220, 14%, 71%)",
|
||||
"--fg": "hsl(220, 14%, 71%)",
|
||||
"--fg-secondary": "hsl(220, 9%, 55%)",
|
||||
"--fg-muted": "hsl(220, 9%, 55%)",
|
||||
"--fg-subtle": "hsl(220, 9%, 55%)",
|
||||
"--fg-faint": "hsl(220, 9%, 55%)",
|
||||
"--fg-gutter": "hsl(220, 9%, 55%)",
|
||||
"--fg-icon": "hsl(220, 14%, 71%)",
|
||||
|
||||
// Accent
|
||||
"--accent": "hsl(220, 100%, 66%)",
|
||||
"--link": "hsl(207, 82%, 66%)",
|
||||
"--link-hover": "hsl(187, 47%, 55%)",
|
||||
|
||||
// Charts
|
||||
"--chart-series": "hsl(355, 65%, 65%)",
|
||||
|
||||
// Status
|
||||
"--danger": "hsl(355, 65%, 65%)",
|
||||
"--warning": "hsl(39, 67%, 69%)",
|
||||
"--success": "hsl(95, 38%, 62%)",
|
||||
"--db-connected": "hsl(95, 38%, 62%)",
|
||||
"--db-connected-ring": "hsl(95, 38%, 62%)",
|
||||
"--info": "hsl(207, 82%, 66%)",
|
||||
|
||||
// Vcs
|
||||
"--vcs-modified": "hsl(207, 82%, 66%)",
|
||||
"--vcs-added": "hsl(95, 38%, 62%)",
|
||||
"--vcs-deleted": "hsl(220, 9%, 55%)",
|
||||
"--vcs-untracked": "hsl(355, 65%, 65%)",
|
||||
"--vcs-ignored": "hsl(39, 67%, 69%)",
|
||||
"--vcs-conflict": "hsl(355, 65%, 65%)",
|
||||
"--gutter-modified": "hsl(207, 82%, 66%)",
|
||||
"--gutter-added": "hsl(95, 38%, 62%)",
|
||||
"--gutter-deleted": "hsl(355, 65%, 65%)",
|
||||
|
||||
// Shadows and window controls
|
||||
"--shadow-popup": "0 4px 16px #00000024",
|
||||
"--shadow-dialog": "0 10px 36px #00000033",
|
||||
"--traffic-close": "#ff5f57",
|
||||
"--traffic-close-border": "#e0443e",
|
||||
"--traffic-close-pressed": "#bf4942",
|
||||
"--traffic-glyph": "#4d0000",
|
||||
"--traffic-off": "hsl(220, 13%, 22%)",
|
||||
"--traffic-off-border": "hsl(220, 13%, 10.8%)",
|
||||
|
||||
// Additive
|
||||
"--bg-tooltip": "hsl(220, 13%, 16.5%)",
|
||||
"--fg-tooltip": "hsl(220, 14%, 71%)",
|
||||
"--border-tooltip": "hsl(220, 13%, 10.8%)",
|
||||
"--bg-control": "hsl(220, 13%, 18%)",
|
||||
"--bg-control-hover": "hsl(220, 13%, 22%)",
|
||||
"--bg-active": "hsl(220, 13%, 22%)",
|
||||
"--bg-scrim": "color-mix(in srgb, hsl(220, 13%, 18%) 68%, transparent)",
|
||||
"--fg-on-accent": "#000000",
|
||||
"--shadow-tooltip": "0 4px 16px #00000024",
|
||||
"--shadow-balloon": "0 10px 36px #00000033",
|
||||
|
||||
// Islands contract
|
||||
"--bg-frame": "hsl(220, 13%, 15%)",
|
||||
"--bg-island": "hsl(220, 13%, 18%)",
|
||||
"--bg-stripe-hover": "hsl(220, 13%, 22%)",
|
||||
"--bg-stripe-selected": "hsl(220, 13%, 28%)",
|
||||
"--fg-stripe-selected-active": "#000000",
|
||||
"--fg-stripe-label": "hsl(220, 14%, 71%)",
|
||||
"--bg-tab-selected": "hsl(220, 13%, 28%)",
|
||||
"--border-tab-selected": "hsl(220, 100%, 66%)",
|
||||
"--bg-tab-selected-inactive": "hsl(220, 13%, 15%)",
|
||||
"--border-tab-selected-inactive": "hsl(220, 13%, 10.8%)",
|
||||
"--bg-tab-hover": "hsl(220, 13%, 22%)",
|
||||
"--border-editor-tabs": "hsl(220, 13%, 10.8%)",
|
||||
"--bg-tree-selected": "hsl(220, 13%, 28%)",
|
||||
"--bg-tree-selected-inactive": "hsl(220, 13%, 22%)",
|
||||
"--bg-tree-hover": "hsl(220, 13%, 22%)",
|
||||
"--bg-toolbar-hover": "hsl(220, 13%, 22%)",
|
||||
"--bg-toolbar-pressed": "hsl(220, 13%, 28%)",
|
||||
"--bg-toolbar-selected": "hsl(220, 13%, 28%)",
|
||||
"--bg-toolbar-selected-hover": "hsl(220, 13%, 28%)",
|
||||
"--bg-button-primary-hover": "color-mix(in srgb, var(--accent) 86%, hsl(220, 14%, 71%))",
|
||||
"--fg-button-primary": "#000000",
|
||||
"--bg-button": "hsl(220, 13%, 18%)",
|
||||
"--border-button": "hsl(220, 13%, 10.8%)",
|
||||
"--bg-field": "hsl(220, 13%, 18%)",
|
||||
"--bg-checkbox": "hsl(220, 13%, 18%)",
|
||||
"--border-checkbox": "hsl(220, 9%, 55%)",
|
||||
"--bg-toggle-on": "hsl(95, 38%, 62%)",
|
||||
"--fg-toggle-on": "#000000",
|
||||
"--bg-toggle-off": "hsl(220, 13%, 15%)",
|
||||
"--fg-toggle-off": "hsl(220, 14%, 71%)",
|
||||
"--border-toggle": "hsl(220, 9%, 55%)",
|
||||
"--bg-toggle-knob": "hsl(220, 9%, 55%)",
|
||||
"--focus-ring-soft": "hsl(220, 100%, 66%)",
|
||||
"--scrollbar-thumb": "color-mix(in srgb, hsl(220, 14%, 71%) 24%, transparent)",
|
||||
"--scrollbar-thumb-hover": "color-mix(in srgb, hsl(220, 14%, 71%) 42%, transparent)",
|
||||
"--bg-search-match": "color-mix(in srgb, hsl(39, 67%, 69%) 22%, hsl(220, 13%, 18%))",
|
||||
"--bg-search-match-current": "color-mix(in srgb, hsl(39, 67%, 69%) 36%, hsl(220, 13%, 18%))",
|
||||
"--fg-search-match": "hsl(220, 14%, 71%)",
|
||||
"--bg-dialog": "hsl(220, 13%, 18%)",
|
||||
"--bg-popup-inline": "hsl(220, 13%, 15%)",
|
||||
"--bg-popup-advertiser": "hsl(220, 13%, 15%)",
|
||||
"--bg-feedback-info": "color-mix(in srgb, hsl(207, 82%, 66%) 12%, hsl(220, 13%, 18%))",
|
||||
"--border-feedback-info": "color-mix(in srgb, hsl(207, 82%, 66%) 55%, hsl(220, 13%, 18%))",
|
||||
"--bg-feedback-error": "color-mix(in srgb, hsl(355, 65%, 65%) 12%, hsl(220, 13%, 18%))",
|
||||
"--border-feedback-error": "color-mix(in srgb, hsl(355, 65%, 65%) 55%, hsl(220, 13%, 18%))",
|
||||
"--bg-feedback-warning": "color-mix(in srgb, hsl(39, 67%, 69%) 12%, hsl(220, 13%, 18%))",
|
||||
"--border-feedback-warning": "color-mix(in srgb, hsl(39, 67%, 69%) 55%, hsl(220, 13%, 18%))",
|
||||
"--bg-feedback-success": "color-mix(in srgb, hsl(95, 38%, 62%) 12%, hsl(220, 13%, 18%))",
|
||||
"--border-feedback-success": "color-mix(in srgb, hsl(95, 38%, 62%) 55%, hsl(220, 13%, 18%))",
|
||||
"--bg-counter": "hsl(220, 100%, 66%)",
|
||||
"--fg-counter": "#000000",
|
||||
"--bg-progress-track": "hsl(220, 13%, 22%)"
|
||||
}
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
// Atom One palette by GitHub Inc. (https://github.com/atom/one-dark-syntax and friends),
|
||||
// MIT licence, see LICENSE. Adapted to OpenIDEA's tokens by bghtyu.
|
||||
// Editor colour scheme: syntax, editor surfaces and terminal ANSI colours.
|
||||
{
|
||||
"name": "One Light",
|
||||
"tokens": {
|
||||
// Syntax
|
||||
"--syn-keyword": "hsl(301, 63%, 40%)",
|
||||
"--syn-string": "hsl(119, 34%, 47%)",
|
||||
"--syn-type": "hsl(41, 99%, 38%)",
|
||||
"--syn-function": "hsl(221, 87%, 60%)",
|
||||
"--syn-function-call": "hsl(221, 87%, 60%)",
|
||||
"--syn-comment": "hsl(230, 4%, 64%)",
|
||||
"--syn-comment-style": "italic",
|
||||
"--syn-doc-comment": "hsl(230, 4%, 64%)",
|
||||
"--syn-docstring": "hsl(119, 34%, 47%)",
|
||||
"--syn-annotation": "hsl(41, 99%, 30%)",
|
||||
"--syn-decorator": "hsl(41, 99%, 30%)",
|
||||
"--syn-number": "hsl(41, 99%, 30%)",
|
||||
"--syn-punct": "hsl(230, 8%, 24%)",
|
||||
"--syn-variable": "hsl(5, 74%, 59%)",
|
||||
"--syn-param": "hsl(230, 8%, 24%)",
|
||||
"--syn-property": "hsl(230, 8%, 24%)",
|
||||
"--syn-constant": "hsl(41, 99%, 30%)",
|
||||
"--syn-builtin": "hsl(198, 99%, 37%)",
|
||||
"--syn-self": "hsl(5, 74%, 59%)",
|
||||
"--syn-keyword-arg": "hsl(5, 74%, 59%)",
|
||||
"--syn-predefined": "hsl(198, 99%, 37%)",
|
||||
"--syn-escape": "hsl(198, 99%, 37%)",
|
||||
"--syn-regexp": "hsl(198, 99%, 37%)",
|
||||
"--syn-tag": "hsl(5, 74%, 59%)",
|
||||
"--syn-attribute": "hsl(41, 99%, 30%)",
|
||||
"--syn-todo": "hsl(301, 63%, 40%)",
|
||||
"--syn-link": "hsl(221, 87%, 60%)",
|
||||
"--syn-markup-heading": "hsl(221, 87%, 60%)",
|
||||
"--syn-markup-code": "hsl(119, 34%, 47%)",
|
||||
"--syn-invalid": "hsl(5, 74%, 59%)",
|
||||
"--syn-inline-value": "hsl(230, 6%, 44%)",
|
||||
"--syn-rainbow-1": "hsl(198, 99%, 37%)",
|
||||
"--syn-rainbow-2": "hsl(41, 99%, 30%)",
|
||||
"--syn-rainbow-3": "hsl(119, 34%, 47%)",
|
||||
"--syn-rainbow-4": "hsl(301, 63%, 40%)",
|
||||
"--syn-rainbow-5": "hsl(221, 87%, 60%)",
|
||||
"--syn-bracket-1": "hsl(41, 99%, 38%)",
|
||||
"--syn-bracket-2": "hsl(301, 63%, 40%)",
|
||||
"--syn-bracket-3": "hsl(221, 87%, 60%)",
|
||||
|
||||
// Editor
|
||||
"--fg-editor": "hsl(230, 8%, 24%)",
|
||||
"--caret": "hsl(230, 100%, 66%)",
|
||||
"--fg-line-number": "hsl(230, 6%, 44%)",
|
||||
"--fg-line-number-current": "hsl(230, 8%, 24%)",
|
||||
"--border-gutter": "hsl(230, 1%, 86%)",
|
||||
"--border-indent-guide": "hsl(230, 1%, 86%)",
|
||||
"--border-indent-guide-active": "hsl(230, 100%, 66%)",
|
||||
"--border-right-margin": "hsl(230, 1%, 86%)",
|
||||
"--bg-editor-selection": "hsl(230, 1%, 90%)",
|
||||
"--bg-editor-selection-inactive": "hsl(230, 1%, 90%)",
|
||||
"--bg-text-search-result": "color-mix(in srgb, hsl(41, 99%, 38%) 22%, hsl(230, 1%, 98%))",
|
||||
"--bg-text-search-result-current": "color-mix(in srgb, hsl(41, 99%, 38%) 36%, hsl(230, 1%, 98%))",
|
||||
"--bg-matched-brace": "hsl(230, 1%, 90%)",
|
||||
"--matched-brace-weight": "var(--fw-code-bold)",
|
||||
"--bg-matched-tag": "hsl(230, 1%, 90%)",
|
||||
"--bg-fold-placeholder": "hsl(230, 1%, 92%)",
|
||||
"--fg-fold-placeholder": "hsl(230, 8%, 24%)",
|
||||
"--fg-fold-marker": "hsl(230, 6%, 44%)",
|
||||
"--fg-whitespace": "hsl(230, 6%, 44%)",
|
||||
"--fg-unused": "hsl(230, 6%, 44%)",
|
||||
"--bg-identifier-under-caret": "hsl(230, 1%, 90%)",
|
||||
"--bg-identifier-under-caret-write": "color-mix(in srgb, hsl(5, 74%, 59%) 12%, hsl(230, 1%, 98%))",
|
||||
"--fg-inlay": "hsl(230, 6%, 44%)",
|
||||
"--bg-inlay": "hsl(230, 1%, 92%)",
|
||||
"--wave-error": "hsl(5, 74%, 59%)",
|
||||
"--wave-warning": "hsl(41, 99%, 38%)",
|
||||
"--editor-error-decoration": "underline wavy var(--wave-error)",
|
||||
"--editor-warning-decoration": "underline wavy var(--wave-warning)",
|
||||
"--editor-warning-background": "color-mix(in srgb, hsl(41, 99%, 38%) 12%, hsl(230, 1%, 98%))",
|
||||
"--bg-breakpoint-line": "color-mix(in srgb, hsl(5, 74%, 59%) 12%, hsl(230, 1%, 98%))",
|
||||
"--fg-completion-match": "hsl(221, 87%, 60%)",
|
||||
"--bg-editor-inline": "hsl(230, 1%, 92%)",
|
||||
"--bg-editor-banner": "color-mix(in srgb, hsl(221, 87%, 60%) 12%, hsl(230, 1%, 98%))",
|
||||
"--fg-weak-warning": "hsl(230, 6%, 44%)",
|
||||
"--fg-bulb": "hsl(41, 99%, 38%)",
|
||||
|
||||
// ANSI palette
|
||||
"--ansi-black": "hsl(230, 8%, 24%)",
|
||||
"--ansi-red": "hsl(5, 74%, 59%)",
|
||||
"--ansi-green": "hsl(119, 34%, 47%)",
|
||||
"--ansi-yellow": "hsl(41, 99%, 38%)",
|
||||
"--ansi-blue": "hsl(221, 87%, 60%)",
|
||||
"--ansi-magenta": "hsl(301, 63%, 40%)",
|
||||
"--ansi-cyan": "hsl(198, 99%, 37%)",
|
||||
"--ansi-white": "hsl(230, 6%, 44%)",
|
||||
"--ansi-bright-black": "hsl(230, 6%, 44%)",
|
||||
"--ansi-bright-red": "hsl(5, 74%, 59%)",
|
||||
"--ansi-bright-green": "hsl(119, 34%, 47%)",
|
||||
"--ansi-bright-yellow": "hsl(41, 99%, 38%)",
|
||||
"--ansi-bright-blue": "hsl(221, 87%, 60%)",
|
||||
"--ansi-bright-magenta": "hsl(301, 63%, 40%)",
|
||||
"--ansi-bright-cyan": "hsl(198, 99%, 37%)",
|
||||
"--ansi-bright-white": "hsl(230, 8%, 24%)"
|
||||
}
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
// Atom One palette by GitHub Inc. (https://github.com/atom/one-dark-syntax and friends),
|
||||
// MIT licence, see LICENSE. Adapted to OpenIDEA's tokens by bghtyu.
|
||||
// UI theme; the editor colour scheme is in one-light.scheme.json.
|
||||
{
|
||||
"id": "one-light",
|
||||
"name": "One Light",
|
||||
"kind": "light",
|
||||
"tokens": {
|
||||
// Surfaces
|
||||
"--bg-app": "hsl(230, 1%, 98%)",
|
||||
"--bg-elev": "hsl(230, 1%, 92%)",
|
||||
"--bg-popup": "hsl(230, 1%, 95%)",
|
||||
"--bg-hover": "hsl(230, 1%, 90%)",
|
||||
"--bg-selected": "hsl(230, 1%, 90%)",
|
||||
"--bg-selected-strong": "hsl(230, 1%, 90%)",
|
||||
"--bg-current-line": "color-mix(in srgb, hsl(230, 8%, 24%) 5%, hsl(230, 1%, 98%))",
|
||||
"--bg-debug-line": "color-mix(in srgb, hsl(221, 87%, 60%) 12%, hsl(230, 1%, 98%))",
|
||||
"--bg-backdrop": "hsl(230, 1%, 92%)",
|
||||
"--bg-input": "hsl(230, 1%, 98%)",
|
||||
|
||||
// Lines
|
||||
"--border": "hsl(230, 1%, 86%)",
|
||||
"--border-popup": "hsl(230, 1%, 86%)",
|
||||
"--border-strong": "hsl(230, 6%, 44%)",
|
||||
"--border-window": "hsl(230, 1%, 86%)",
|
||||
"--control-off": "hsl(230, 6%, 44%)",
|
||||
|
||||
// Text
|
||||
"--fg-strong": "hsl(230, 8%, 24%)",
|
||||
"--fg-emphasis": "hsl(230, 8%, 24%)",
|
||||
"--fg": "hsl(230, 8%, 24%)",
|
||||
"--fg-secondary": "hsl(230, 6%, 44%)",
|
||||
"--fg-muted": "hsl(230, 6%, 44%)",
|
||||
"--fg-subtle": "hsl(230, 6%, 44%)",
|
||||
"--fg-faint": "hsl(230, 6%, 44%)",
|
||||
"--fg-gutter": "hsl(230, 6%, 44%)",
|
||||
"--fg-icon": "hsl(230, 8%, 24%)",
|
||||
|
||||
// Accent
|
||||
"--accent": "hsl(230, 100%, 66%)",
|
||||
"--link": "hsl(221, 87%, 60%)",
|
||||
"--link-hover": "hsl(198, 99%, 37%)",
|
||||
|
||||
// Charts
|
||||
"--chart-series": "hsl(5, 74%, 59%)",
|
||||
|
||||
// Status
|
||||
"--danger": "hsl(5, 74%, 59%)",
|
||||
"--warning": "hsl(41, 99%, 38%)",
|
||||
"--success": "hsl(119, 34%, 47%)",
|
||||
"--db-connected": "hsl(119, 34%, 47%)",
|
||||
"--db-connected-ring": "hsl(119, 34%, 47%)",
|
||||
"--info": "hsl(221, 87%, 60%)",
|
||||
|
||||
// Vcs
|
||||
"--vcs-modified": "hsl(221, 87%, 60%)",
|
||||
"--vcs-added": "hsl(119, 34%, 47%)",
|
||||
"--vcs-deleted": "hsl(230, 6%, 44%)",
|
||||
"--vcs-untracked": "hsl(5, 74%, 59%)",
|
||||
"--vcs-ignored": "hsl(41, 99%, 38%)",
|
||||
"--vcs-conflict": "hsl(5, 74%, 59%)",
|
||||
"--gutter-modified": "hsl(221, 87%, 60%)",
|
||||
"--gutter-added": "hsl(119, 34%, 47%)",
|
||||
"--gutter-deleted": "hsl(5, 74%, 59%)",
|
||||
|
||||
// Shadows and window controls
|
||||
"--shadow-popup": "0 4px 16px #00000024",
|
||||
"--shadow-dialog": "0 10px 36px #00000033",
|
||||
"--traffic-close": "#ff5f57",
|
||||
"--traffic-close-border": "#e0443e",
|
||||
"--traffic-close-pressed": "#bf4942",
|
||||
"--traffic-glyph": "#4d0000",
|
||||
"--traffic-off": "hsl(230, 1%, 90%)",
|
||||
"--traffic-off-border": "hsl(230, 1%, 86%)",
|
||||
|
||||
// Additive
|
||||
"--bg-tooltip": "hsl(230, 1%, 95%)",
|
||||
"--fg-tooltip": "hsl(230, 8%, 24%)",
|
||||
"--border-tooltip": "hsl(230, 1%, 86%)",
|
||||
"--bg-control": "hsl(230, 1%, 98%)",
|
||||
"--bg-control-hover": "hsl(230, 1%, 90%)",
|
||||
"--bg-active": "hsl(230, 1%, 90%)",
|
||||
"--bg-scrim": "color-mix(in srgb, hsl(230, 1%, 98%) 68%, transparent)",
|
||||
"--fg-on-accent": "#ffffff",
|
||||
"--shadow-tooltip": "0 4px 16px #00000024",
|
||||
"--shadow-balloon": "0 10px 36px #00000033",
|
||||
|
||||
// Islands contract
|
||||
"--bg-frame": "hsl(230, 1%, 92%)",
|
||||
"--bg-island": "hsl(230, 1%, 98%)",
|
||||
"--bg-stripe-hover": "hsl(230, 1%, 90%)",
|
||||
"--bg-stripe-selected": "hsl(230, 1%, 90%)",
|
||||
"--fg-stripe-selected-active": "#ffffff",
|
||||
"--fg-stripe-label": "hsl(230, 8%, 24%)",
|
||||
"--bg-tab-selected": "hsl(230, 1%, 90%)",
|
||||
"--border-tab-selected": "hsl(230, 100%, 66%)",
|
||||
"--bg-tab-selected-inactive": "hsl(230, 1%, 92%)",
|
||||
"--border-tab-selected-inactive": "hsl(230, 1%, 86%)",
|
||||
"--bg-tab-hover": "hsl(230, 1%, 90%)",
|
||||
"--border-editor-tabs": "hsl(230, 1%, 86%)",
|
||||
"--bg-tree-selected": "hsl(230, 1%, 90%)",
|
||||
"--bg-tree-selected-inactive": "hsl(230, 1%, 90%)",
|
||||
"--bg-tree-hover": "hsl(230, 1%, 90%)",
|
||||
"--bg-toolbar-hover": "hsl(230, 1%, 90%)",
|
||||
"--bg-toolbar-pressed": "hsl(230, 1%, 90%)",
|
||||
"--bg-toolbar-selected": "hsl(230, 1%, 90%)",
|
||||
"--bg-toolbar-selected-hover": "hsl(230, 1%, 90%)",
|
||||
"--bg-button-primary-hover": "color-mix(in srgb, var(--accent) 86%, hsl(230, 8%, 24%))",
|
||||
"--fg-button-primary": "#ffffff",
|
||||
"--bg-button": "hsl(230, 1%, 98%)",
|
||||
"--border-button": "hsl(230, 1%, 86%)",
|
||||
"--bg-field": "hsl(230, 1%, 98%)",
|
||||
"--bg-checkbox": "hsl(230, 1%, 98%)",
|
||||
"--border-checkbox": "hsl(230, 6%, 44%)",
|
||||
"--bg-toggle-on": "hsl(119, 34%, 47%)",
|
||||
"--fg-toggle-on": "#ffffff",
|
||||
"--bg-toggle-off": "hsl(230, 1%, 92%)",
|
||||
"--fg-toggle-off": "hsl(230, 8%, 24%)",
|
||||
"--border-toggle": "hsl(230, 6%, 44%)",
|
||||
"--bg-toggle-knob": "hsl(230, 6%, 44%)",
|
||||
"--focus-ring-soft": "hsl(230, 100%, 66%)",
|
||||
"--scrollbar-thumb": "color-mix(in srgb, hsl(230, 8%, 24%) 24%, transparent)",
|
||||
"--scrollbar-thumb-hover": "color-mix(in srgb, hsl(230, 8%, 24%) 42%, transparent)",
|
||||
"--bg-search-match": "color-mix(in srgb, hsl(41, 99%, 38%) 22%, hsl(230, 1%, 98%))",
|
||||
"--bg-search-match-current": "color-mix(in srgb, hsl(41, 99%, 38%) 36%, hsl(230, 1%, 98%))",
|
||||
"--fg-search-match": "hsl(230, 8%, 24%)",
|
||||
"--bg-dialog": "hsl(230, 1%, 98%)",
|
||||
"--bg-popup-inline": "hsl(230, 1%, 92%)",
|
||||
"--bg-popup-advertiser": "hsl(230, 1%, 92%)",
|
||||
"--bg-feedback-info": "color-mix(in srgb, hsl(221, 87%, 60%) 12%, hsl(230, 1%, 98%))",
|
||||
"--border-feedback-info": "color-mix(in srgb, hsl(221, 87%, 60%) 55%, hsl(230, 1%, 98%))",
|
||||
"--bg-feedback-error": "color-mix(in srgb, hsl(5, 74%, 59%) 12%, hsl(230, 1%, 98%))",
|
||||
"--border-feedback-error": "color-mix(in srgb, hsl(5, 74%, 59%) 55%, hsl(230, 1%, 98%))",
|
||||
"--bg-feedback-warning": "color-mix(in srgb, hsl(41, 99%, 38%) 12%, hsl(230, 1%, 98%))",
|
||||
"--border-feedback-warning": "color-mix(in srgb, hsl(41, 99%, 38%) 55%, hsl(230, 1%, 98%))",
|
||||
"--bg-feedback-success": "color-mix(in srgb, hsl(119, 34%, 47%) 12%, hsl(230, 1%, 98%))",
|
||||
"--border-feedback-success": "color-mix(in srgb, hsl(119, 34%, 47%) 55%, hsl(230, 1%, 98%))",
|
||||
"--bg-counter": "hsl(230, 100%, 66%)",
|
||||
"--fg-counter": "#ffffff",
|
||||
"--bg-progress-track": "hsl(230, 1%, 90%)"
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
The Solarized palette is adapted from Ethan Schoonover's Solarized,
|
||||
https://github.com/altercation/solarized (revision 62f656a02f93c5190a8753159e34b385588d5ff3):
|
||||
the sixteen sRGB colours of its README, the semantic roles of
|
||||
vim-colors-solarized/colors/solarized.vim and its iTerm2 ANSI slots.
|
||||
Adapted to OpenIDEA's design tokens by bghtyu.
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2011 Ethan Schoonover
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -1,17 +0,0 @@
|
||||
# Contribution-only theme plugin: no code, just theme and editor scheme files.
|
||||
id = "theme-solarized"
|
||||
name = "Solarized Themes"
|
||||
version = "1.0.0"
|
||||
description = "Solarized Light and Solarized Dark: Ethan Schoonover's Solarized palette for the UI, the editor and the terminal."
|
||||
authors = ["bghtyu <[email protected]>", "Ethan Schoonover (Solarized palette)"]
|
||||
homepage = "https://github.com/altercation/solarized"
|
||||
change-notes = "1.0.0 — Solarized Light and Solarized Dark: UI, editor colour scheme and terminal ANSI colours."
|
||||
openidea-api = "0.1"
|
||||
|
||||
[[contributes.themes]]
|
||||
path = "themes/solarized-light.theme.json"
|
||||
editor-scheme = "themes/solarized-light.scheme.json"
|
||||
|
||||
[[contributes.themes]]
|
||||
path = "themes/solarized-dark.theme.json"
|
||||
editor-scheme = "themes/solarized-dark.scheme.json"
|
||||
@@ -1,103 +0,0 @@
|
||||
// Solarized palette by Ethan Schoonover (https://github.com/altercation/solarized),
|
||||
// MIT licence, see LICENSE. Adapted to OpenIDEA's tokens by bghtyu.
|
||||
// Editor colour scheme: syntax, editor surfaces and terminal ANSI colours.
|
||||
{
|
||||
"name": "Solarized Dark",
|
||||
"tokens": {
|
||||
// Syntax
|
||||
"--syn-keyword": "#859900",
|
||||
"--syn-string": "#2aa198",
|
||||
"--syn-type": "#b58900",
|
||||
"--syn-function": "#268bd2",
|
||||
"--syn-function-call": "#268bd2",
|
||||
"--syn-comment": "#586e75",
|
||||
"--syn-comment-style": "italic",
|
||||
"--syn-doc-comment": "#586e75",
|
||||
"--syn-docstring": "#2aa198",
|
||||
"--syn-annotation": "#cb4b16",
|
||||
"--syn-decorator": "#cb4b16",
|
||||
"--syn-number": "#2aa198",
|
||||
"--syn-punct": "#839496",
|
||||
"--syn-variable": "#268bd2",
|
||||
"--syn-param": "#839496",
|
||||
"--syn-property": "#268bd2",
|
||||
"--syn-constant": "#2aa198",
|
||||
"--syn-builtin": "#2aa198",
|
||||
"--syn-self": "#dc322f",
|
||||
"--syn-keyword-arg": "#dc322f",
|
||||
"--syn-predefined": "#2aa198",
|
||||
"--syn-escape": "#dc322f",
|
||||
"--syn-regexp": "#2aa198",
|
||||
"--syn-tag": "#268bd2",
|
||||
"--syn-attribute": "#cb4b16",
|
||||
"--syn-todo": "#d33682",
|
||||
"--syn-link": "#268bd2",
|
||||
"--syn-markup-heading": "#268bd2",
|
||||
"--syn-markup-code": "#2aa198",
|
||||
"--syn-invalid": "#dc322f",
|
||||
"--syn-inline-value": "#839496",
|
||||
"--syn-rainbow-1": "#2aa198",
|
||||
"--syn-rainbow-2": "#cb4b16",
|
||||
"--syn-rainbow-3": "#859900",
|
||||
"--syn-rainbow-4": "#d33682",
|
||||
"--syn-rainbow-5": "#268bd2",
|
||||
"--syn-bracket-1": "#b58900",
|
||||
"--syn-bracket-2": "#d33682",
|
||||
"--syn-bracket-3": "#268bd2",
|
||||
|
||||
// Editor
|
||||
"--fg-editor": "#839496",
|
||||
"--caret": "#268bd2",
|
||||
"--fg-line-number": "#839496",
|
||||
"--fg-line-number-current": "#839496",
|
||||
"--border-gutter": "#073642",
|
||||
"--border-indent-guide": "#073642",
|
||||
"--border-indent-guide-active": "#268bd2",
|
||||
"--border-right-margin": "#073642",
|
||||
"--bg-editor-selection": "#073642",
|
||||
"--bg-editor-selection-inactive": "#073642",
|
||||
"--bg-text-search-result": "color-mix(in srgb, #b58900 22%, #002b36)",
|
||||
"--bg-text-search-result-current": "color-mix(in srgb, #b58900 36%, #002b36)",
|
||||
"--bg-matched-brace": "#073642",
|
||||
"--matched-brace-weight": "var(--fw-code-bold)",
|
||||
"--bg-matched-tag": "#073642",
|
||||
"--bg-fold-placeholder": "#073642",
|
||||
"--fg-fold-placeholder": "#839496",
|
||||
"--fg-fold-marker": "#839496",
|
||||
"--fg-whitespace": "#839496",
|
||||
"--fg-unused": "#839496",
|
||||
"--bg-identifier-under-caret": "#073642",
|
||||
"--bg-identifier-under-caret-write": "color-mix(in srgb, #dc322f 12%, #002b36)",
|
||||
"--fg-inlay": "#839496",
|
||||
"--bg-inlay": "#073642",
|
||||
"--wave-error": "#dc322f",
|
||||
"--wave-warning": "#b58900",
|
||||
"--editor-error-decoration": "underline wavy var(--wave-error)",
|
||||
"--editor-warning-decoration": "underline wavy var(--wave-warning)",
|
||||
"--editor-warning-background": "color-mix(in srgb, #b58900 12%, #002b36)",
|
||||
"--bg-breakpoint-line": "color-mix(in srgb, #dc322f 12%, #002b36)",
|
||||
"--fg-completion-match": "#268bd2",
|
||||
"--bg-editor-inline": "#073642",
|
||||
"--bg-editor-banner": "color-mix(in srgb, #268bd2 12%, #002b36)",
|
||||
"--fg-weak-warning": "#839496",
|
||||
"--fg-bulb": "#b58900",
|
||||
|
||||
// ANSI palette
|
||||
"--ansi-black": "#073642",
|
||||
"--ansi-red": "#dc322f",
|
||||
"--ansi-green": "#859900",
|
||||
"--ansi-yellow": "#b58900",
|
||||
"--ansi-blue": "#268bd2",
|
||||
"--ansi-magenta": "#d33682",
|
||||
"--ansi-cyan": "#2aa198",
|
||||
"--ansi-white": "#eee8d5",
|
||||
"--ansi-bright-black": "#002b36",
|
||||
"--ansi-bright-red": "#cb4b16",
|
||||
"--ansi-bright-green": "#586e75",
|
||||
"--ansi-bright-yellow": "#657b83",
|
||||
"--ansi-bright-blue": "#839496",
|
||||
"--ansi-bright-magenta": "#6c71c4",
|
||||
"--ansi-bright-cyan": "#93a1a1",
|
||||
"--ansi-bright-white": "#fdf6e3"
|
||||
}
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
// Solarized palette by Ethan Schoonover (https://github.com/altercation/solarized),
|
||||
// MIT licence, see LICENSE. Adapted to OpenIDEA's tokens by bghtyu.
|
||||
// UI theme; the editor colour scheme is in solarized-dark.scheme.json.
|
||||
{
|
||||
"id": "solarized-dark",
|
||||
"name": "Solarized Dark",
|
||||
"kind": "dark",
|
||||
"tokens": {
|
||||
// Surfaces
|
||||
"--bg-app": "#002b36",
|
||||
"--bg-elev": "#073642",
|
||||
"--bg-popup": "#073642",
|
||||
"--bg-hover": "#073642",
|
||||
"--bg-selected": "#073642",
|
||||
"--bg-selected-strong": "#073642",
|
||||
"--bg-current-line": "#073642",
|
||||
"--bg-debug-line": "color-mix(in srgb, #268bd2 12%, #002b36)",
|
||||
"--bg-backdrop": "#073642",
|
||||
"--bg-input": "#002b36",
|
||||
|
||||
// Lines
|
||||
"--border": "#073642",
|
||||
"--border-popup": "#073642",
|
||||
"--border-strong": "#839496",
|
||||
"--border-window": "#073642",
|
||||
"--control-off": "#839496",
|
||||
|
||||
// Text
|
||||
"--fg-strong": "#839496",
|
||||
"--fg-emphasis": "#839496",
|
||||
"--fg": "#839496",
|
||||
"--fg-secondary": "#839496",
|
||||
"--fg-muted": "#839496",
|
||||
"--fg-subtle": "#839496",
|
||||
"--fg-faint": "#839496",
|
||||
"--fg-gutter": "#839496",
|
||||
"--fg-icon": "#839496",
|
||||
|
||||
// Accent
|
||||
"--accent": "#268bd2",
|
||||
"--link": "#268bd2",
|
||||
"--link-hover": "#2aa198",
|
||||
|
||||
// Charts
|
||||
"--chart-series": "#dc322f",
|
||||
|
||||
// Status
|
||||
"--danger": "#dc322f",
|
||||
"--warning": "#b58900",
|
||||
"--success": "#859900",
|
||||
"--db-connected": "#859900",
|
||||
"--db-connected-ring": "#859900",
|
||||
"--info": "#268bd2",
|
||||
|
||||
// Vcs
|
||||
"--vcs-modified": "#268bd2",
|
||||
"--vcs-added": "#859900",
|
||||
"--vcs-deleted": "#839496",
|
||||
"--vcs-untracked": "#dc322f",
|
||||
"--vcs-ignored": "#b58900",
|
||||
"--vcs-conflict": "#dc322f",
|
||||
"--gutter-modified": "#268bd2",
|
||||
"--gutter-added": "#859900",
|
||||
"--gutter-deleted": "#dc322f",
|
||||
|
||||
// Shadows and window controls
|
||||
"--shadow-popup": "0 4px 16px #00000024",
|
||||
"--shadow-dialog": "0 10px 36px #00000033",
|
||||
"--traffic-close": "#ff5f57",
|
||||
"--traffic-close-border": "#e0443e",
|
||||
"--traffic-close-pressed": "#bf4942",
|
||||
"--traffic-glyph": "#4d0000",
|
||||
"--traffic-off": "#073642",
|
||||
"--traffic-off-border": "#073642",
|
||||
|
||||
// Additive
|
||||
"--bg-tooltip": "#073642",
|
||||
"--fg-tooltip": "#839496",
|
||||
"--border-tooltip": "#073642",
|
||||
"--bg-control": "#002b36",
|
||||
"--bg-control-hover": "#073642",
|
||||
"--bg-active": "#073642",
|
||||
"--bg-scrim": "color-mix(in srgb, #002b36 68%, transparent)",
|
||||
"--fg-on-accent": "#002b36",
|
||||
"--shadow-tooltip": "0 4px 16px #00000024",
|
||||
"--shadow-balloon": "0 10px 36px #00000033",
|
||||
|
||||
// Islands contract
|
||||
"--bg-frame": "#073642",
|
||||
"--bg-island": "#002b36",
|
||||
"--bg-stripe-hover": "#073642",
|
||||
"--bg-stripe-selected": "#073642",
|
||||
"--fg-stripe-selected-active": "#002b36",
|
||||
"--fg-stripe-label": "#839496",
|
||||
"--bg-tab-selected": "#073642",
|
||||
"--border-tab-selected": "#268bd2",
|
||||
"--bg-tab-selected-inactive": "#073642",
|
||||
"--border-tab-selected-inactive": "#073642",
|
||||
"--bg-tab-hover": "#073642",
|
||||
"--border-editor-tabs": "#073642",
|
||||
"--bg-tree-selected": "#073642",
|
||||
"--bg-tree-selected-inactive": "#073642",
|
||||
"--bg-tree-hover": "#073642",
|
||||
"--bg-toolbar-hover": "#073642",
|
||||
"--bg-toolbar-pressed": "#073642",
|
||||
"--bg-toolbar-selected": "#073642",
|
||||
"--bg-toolbar-selected-hover": "#073642",
|
||||
"--bg-button-primary-hover": "color-mix(in srgb, var(--accent) 86%, #839496)",
|
||||
"--fg-button-primary": "#002b36",
|
||||
"--bg-button": "#002b36",
|
||||
"--border-button": "#073642",
|
||||
"--bg-field": "#002b36",
|
||||
"--bg-checkbox": "#002b36",
|
||||
"--border-checkbox": "#839496",
|
||||
"--bg-toggle-on": "#859900",
|
||||
"--fg-toggle-on": "#002b36",
|
||||
"--bg-toggle-off": "#073642",
|
||||
"--fg-toggle-off": "#839496",
|
||||
"--border-toggle": "#839496",
|
||||
"--bg-toggle-knob": "#839496",
|
||||
"--focus-ring-soft": "#268bd2",
|
||||
"--scrollbar-thumb": "color-mix(in srgb, #839496 24%, transparent)",
|
||||
"--scrollbar-thumb-hover": "color-mix(in srgb, #839496 42%, transparent)",
|
||||
"--bg-search-match": "color-mix(in srgb, #b58900 22%, #002b36)",
|
||||
"--bg-search-match-current": "color-mix(in srgb, #b58900 36%, #002b36)",
|
||||
"--fg-search-match": "#839496",
|
||||
"--bg-dialog": "#002b36",
|
||||
"--bg-popup-inline": "#073642",
|
||||
"--bg-popup-advertiser": "#073642",
|
||||
"--bg-feedback-info": "color-mix(in srgb, #268bd2 12%, #002b36)",
|
||||
"--border-feedback-info": "color-mix(in srgb, #268bd2 55%, #002b36)",
|
||||
"--bg-feedback-error": "color-mix(in srgb, #dc322f 12%, #002b36)",
|
||||
"--border-feedback-error": "color-mix(in srgb, #dc322f 55%, #002b36)",
|
||||
"--bg-feedback-warning": "color-mix(in srgb, #b58900 12%, #002b36)",
|
||||
"--border-feedback-warning": "color-mix(in srgb, #b58900 55%, #002b36)",
|
||||
"--bg-feedback-success": "color-mix(in srgb, #859900 12%, #002b36)",
|
||||
"--border-feedback-success": "color-mix(in srgb, #859900 55%, #002b36)",
|
||||
"--bg-counter": "#268bd2",
|
||||
"--fg-counter": "#002b36",
|
||||
"--bg-progress-track": "#073642"
|
||||
}
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
// Solarized palette by Ethan Schoonover (https://github.com/altercation/solarized),
|
||||
// MIT licence, see LICENSE. Adapted to OpenIDEA's tokens by bghtyu.
|
||||
// Editor colour scheme: syntax, editor surfaces and terminal ANSI colours.
|
||||
{
|
||||
"name": "Solarized Light",
|
||||
"tokens": {
|
||||
// Syntax
|
||||
"--syn-keyword": "#859900",
|
||||
"--syn-string": "#2aa198",
|
||||
"--syn-type": "#b58900",
|
||||
"--syn-function": "#268bd2",
|
||||
"--syn-function-call": "#268bd2",
|
||||
"--syn-comment": "#93a1a1",
|
||||
"--syn-comment-style": "italic",
|
||||
"--syn-doc-comment": "#93a1a1",
|
||||
"--syn-docstring": "#2aa198",
|
||||
"--syn-annotation": "#cb4b16",
|
||||
"--syn-decorator": "#cb4b16",
|
||||
"--syn-number": "#2aa198",
|
||||
"--syn-punct": "#657b83",
|
||||
"--syn-variable": "#268bd2",
|
||||
"--syn-param": "#657b83",
|
||||
"--syn-property": "#268bd2",
|
||||
"--syn-constant": "#2aa198",
|
||||
"--syn-builtin": "#2aa198",
|
||||
"--syn-self": "#dc322f",
|
||||
"--syn-keyword-arg": "#dc322f",
|
||||
"--syn-predefined": "#2aa198",
|
||||
"--syn-escape": "#dc322f",
|
||||
"--syn-regexp": "#2aa198",
|
||||
"--syn-tag": "#268bd2",
|
||||
"--syn-attribute": "#cb4b16",
|
||||
"--syn-todo": "#d33682",
|
||||
"--syn-link": "#268bd2",
|
||||
"--syn-markup-heading": "#268bd2",
|
||||
"--syn-markup-code": "#2aa198",
|
||||
"--syn-invalid": "#dc322f",
|
||||
"--syn-inline-value": "#657b83",
|
||||
"--syn-rainbow-1": "#2aa198",
|
||||
"--syn-rainbow-2": "#cb4b16",
|
||||
"--syn-rainbow-3": "#859900",
|
||||
"--syn-rainbow-4": "#d33682",
|
||||
"--syn-rainbow-5": "#268bd2",
|
||||
"--syn-bracket-1": "#b58900",
|
||||
"--syn-bracket-2": "#d33682",
|
||||
"--syn-bracket-3": "#268bd2",
|
||||
|
||||
// Editor
|
||||
"--fg-editor": "#657b83",
|
||||
"--caret": "#268bd2",
|
||||
"--fg-line-number": "#657b83",
|
||||
"--fg-line-number-current": "#657b83",
|
||||
"--border-gutter": "#eee8d5",
|
||||
"--border-indent-guide": "#eee8d5",
|
||||
"--border-indent-guide-active": "#268bd2",
|
||||
"--border-right-margin": "#eee8d5",
|
||||
"--bg-editor-selection": "#eee8d5",
|
||||
"--bg-editor-selection-inactive": "#eee8d5",
|
||||
"--bg-text-search-result": "color-mix(in srgb, #b58900 22%, #fdf6e3)",
|
||||
"--bg-text-search-result-current": "color-mix(in srgb, #b58900 36%, #fdf6e3)",
|
||||
"--bg-matched-brace": "#eee8d5",
|
||||
"--matched-brace-weight": "var(--fw-code-bold)",
|
||||
"--bg-matched-tag": "#eee8d5",
|
||||
"--bg-fold-placeholder": "#eee8d5",
|
||||
"--fg-fold-placeholder": "#657b83",
|
||||
"--fg-fold-marker": "#657b83",
|
||||
"--fg-whitespace": "#657b83",
|
||||
"--fg-unused": "#657b83",
|
||||
"--bg-identifier-under-caret": "#eee8d5",
|
||||
"--bg-identifier-under-caret-write": "color-mix(in srgb, #dc322f 12%, #fdf6e3)",
|
||||
"--fg-inlay": "#657b83",
|
||||
"--bg-inlay": "#eee8d5",
|
||||
"--wave-error": "#dc322f",
|
||||
"--wave-warning": "#b58900",
|
||||
"--editor-error-decoration": "underline wavy var(--wave-error)",
|
||||
"--editor-warning-decoration": "underline wavy var(--wave-warning)",
|
||||
"--editor-warning-background": "color-mix(in srgb, #b58900 12%, #fdf6e3)",
|
||||
"--bg-breakpoint-line": "color-mix(in srgb, #dc322f 12%, #fdf6e3)",
|
||||
"--fg-completion-match": "#268bd2",
|
||||
"--bg-editor-inline": "#eee8d5",
|
||||
"--bg-editor-banner": "color-mix(in srgb, #268bd2 12%, #fdf6e3)",
|
||||
"--fg-weak-warning": "#657b83",
|
||||
"--fg-bulb": "#b58900",
|
||||
|
||||
// ANSI palette
|
||||
"--ansi-black": "#073642",
|
||||
"--ansi-red": "#dc322f",
|
||||
"--ansi-green": "#859900",
|
||||
"--ansi-yellow": "#b58900",
|
||||
"--ansi-blue": "#268bd2",
|
||||
"--ansi-magenta": "#d33682",
|
||||
"--ansi-cyan": "#2aa198",
|
||||
"--ansi-white": "#eee8d5",
|
||||
"--ansi-bright-black": "#002b36",
|
||||
"--ansi-bright-red": "#cb4b16",
|
||||
"--ansi-bright-green": "#586e75",
|
||||
"--ansi-bright-yellow": "#657b83",
|
||||
"--ansi-bright-blue": "#839496",
|
||||
"--ansi-bright-magenta": "#6c71c4",
|
||||
"--ansi-bright-cyan": "#93a1a1",
|
||||
"--ansi-bright-white": "#fdf6e3"
|
||||
}
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
// Solarized palette by Ethan Schoonover (https://github.com/altercation/solarized),
|
||||
// MIT licence, see LICENSE. Adapted to OpenIDEA's tokens by bghtyu.
|
||||
// UI theme; the editor colour scheme is in solarized-light.scheme.json.
|
||||
{
|
||||
"id": "solarized-light",
|
||||
"name": "Solarized Light",
|
||||
"kind": "light",
|
||||
"tokens": {
|
||||
// Surfaces
|
||||
"--bg-app": "#fdf6e3",
|
||||
"--bg-elev": "#eee8d5",
|
||||
"--bg-popup": "#fdf6e3",
|
||||
"--bg-hover": "#eee8d5",
|
||||
"--bg-selected": "#eee8d5",
|
||||
"--bg-selected-strong": "#eee8d5",
|
||||
"--bg-current-line": "#eee8d5",
|
||||
"--bg-debug-line": "color-mix(in srgb, #268bd2 12%, #fdf6e3)",
|
||||
"--bg-backdrop": "#eee8d5",
|
||||
"--bg-input": "#fdf6e3",
|
||||
|
||||
// Lines
|
||||
"--border": "#eee8d5",
|
||||
"--border-popup": "#eee8d5",
|
||||
"--border-strong": "#657b83",
|
||||
"--border-window": "#eee8d5",
|
||||
"--control-off": "#657b83",
|
||||
|
||||
// Text
|
||||
"--fg-strong": "#657b83",
|
||||
"--fg-emphasis": "#657b83",
|
||||
"--fg": "#657b83",
|
||||
"--fg-secondary": "#657b83",
|
||||
"--fg-muted": "#657b83",
|
||||
"--fg-subtle": "#657b83",
|
||||
"--fg-faint": "#657b83",
|
||||
"--fg-gutter": "#657b83",
|
||||
"--fg-icon": "#657b83",
|
||||
|
||||
// Accent
|
||||
"--accent": "#268bd2",
|
||||
"--link": "#268bd2",
|
||||
"--link-hover": "#2aa198",
|
||||
|
||||
// Charts
|
||||
"--chart-series": "#dc322f",
|
||||
|
||||
// Status
|
||||
"--danger": "#dc322f",
|
||||
"--warning": "#b58900",
|
||||
"--success": "#859900",
|
||||
"--db-connected": "#859900",
|
||||
"--db-connected-ring": "#859900",
|
||||
"--info": "#268bd2",
|
||||
|
||||
// Vcs
|
||||
"--vcs-modified": "#268bd2",
|
||||
"--vcs-added": "#859900",
|
||||
"--vcs-deleted": "#657b83",
|
||||
"--vcs-untracked": "#dc322f",
|
||||
"--vcs-ignored": "#b58900",
|
||||
"--vcs-conflict": "#dc322f",
|
||||
"--gutter-modified": "#268bd2",
|
||||
"--gutter-added": "#859900",
|
||||
"--gutter-deleted": "#dc322f",
|
||||
|
||||
// Shadows and window controls
|
||||
"--shadow-popup": "0 4px 16px #00000024",
|
||||
"--shadow-dialog": "0 10px 36px #00000033",
|
||||
"--traffic-close": "#ff5f57",
|
||||
"--traffic-close-border": "#e0443e",
|
||||
"--traffic-close-pressed": "#bf4942",
|
||||
"--traffic-glyph": "#4d0000",
|
||||
"--traffic-off": "#eee8d5",
|
||||
"--traffic-off-border": "#eee8d5",
|
||||
|
||||
// Additive
|
||||
"--bg-tooltip": "#fdf6e3",
|
||||
"--fg-tooltip": "#657b83",
|
||||
"--border-tooltip": "#eee8d5",
|
||||
"--bg-control": "#fdf6e3",
|
||||
"--bg-control-hover": "#eee8d5",
|
||||
"--bg-active": "#eee8d5",
|
||||
"--bg-scrim": "color-mix(in srgb, #fdf6e3 68%, transparent)",
|
||||
"--fg-on-accent": "#002b36",
|
||||
"--shadow-tooltip": "0 4px 16px #00000024",
|
||||
"--shadow-balloon": "0 10px 36px #00000033",
|
||||
|
||||
// Islands contract
|
||||
"--bg-frame": "#eee8d5",
|
||||
"--bg-island": "#fdf6e3",
|
||||
"--bg-stripe-hover": "#eee8d5",
|
||||
"--bg-stripe-selected": "#eee8d5",
|
||||
"--fg-stripe-selected-active": "#002b36",
|
||||
"--fg-stripe-label": "#657b83",
|
||||
"--bg-tab-selected": "#eee8d5",
|
||||
"--border-tab-selected": "#268bd2",
|
||||
"--bg-tab-selected-inactive": "#eee8d5",
|
||||
"--border-tab-selected-inactive": "#eee8d5",
|
||||
"--bg-tab-hover": "#eee8d5",
|
||||
"--border-editor-tabs": "#eee8d5",
|
||||
"--bg-tree-selected": "#eee8d5",
|
||||
"--bg-tree-selected-inactive": "#eee8d5",
|
||||
"--bg-tree-hover": "#eee8d5",
|
||||
"--bg-toolbar-hover": "#eee8d5",
|
||||
"--bg-toolbar-pressed": "#eee8d5",
|
||||
"--bg-toolbar-selected": "#eee8d5",
|
||||
"--bg-toolbar-selected-hover": "#eee8d5",
|
||||
"--bg-button-primary-hover": "color-mix(in srgb, var(--accent) 86%, #657b83)",
|
||||
"--fg-button-primary": "#002b36",
|
||||
"--bg-button": "#fdf6e3",
|
||||
"--border-button": "#eee8d5",
|
||||
"--bg-field": "#fdf6e3",
|
||||
"--bg-checkbox": "#fdf6e3",
|
||||
"--border-checkbox": "#657b83",
|
||||
"--bg-toggle-on": "#859900",
|
||||
"--fg-toggle-on": "#002b36",
|
||||
"--bg-toggle-off": "#eee8d5",
|
||||
"--fg-toggle-off": "#657b83",
|
||||
"--border-toggle": "#657b83",
|
||||
"--bg-toggle-knob": "#657b83",
|
||||
"--focus-ring-soft": "#268bd2",
|
||||
"--scrollbar-thumb": "color-mix(in srgb, #657b83 24%, transparent)",
|
||||
"--scrollbar-thumb-hover": "color-mix(in srgb, #657b83 42%, transparent)",
|
||||
"--bg-search-match": "color-mix(in srgb, #b58900 22%, #fdf6e3)",
|
||||
"--bg-search-match-current": "color-mix(in srgb, #b58900 36%, #fdf6e3)",
|
||||
"--fg-search-match": "#657b83",
|
||||
"--bg-dialog": "#fdf6e3",
|
||||
"--bg-popup-inline": "#eee8d5",
|
||||
"--bg-popup-advertiser": "#eee8d5",
|
||||
"--bg-feedback-info": "color-mix(in srgb, #268bd2 12%, #fdf6e3)",
|
||||
"--border-feedback-info": "color-mix(in srgb, #268bd2 55%, #fdf6e3)",
|
||||
"--bg-feedback-error": "color-mix(in srgb, #dc322f 12%, #fdf6e3)",
|
||||
"--border-feedback-error": "color-mix(in srgb, #dc322f 55%, #fdf6e3)",
|
||||
"--bg-feedback-warning": "color-mix(in srgb, #b58900 12%, #fdf6e3)",
|
||||
"--border-feedback-warning": "color-mix(in srgb, #b58900 55%, #fdf6e3)",
|
||||
"--bg-feedback-success": "color-mix(in srgb, #859900 12%, #fdf6e3)",
|
||||
"--border-feedback-success": "color-mix(in srgb, #859900 55%, #fdf6e3)",
|
||||
"--bg-counter": "#268bd2",
|
||||
"--fg-counter": "#002b36",
|
||||
"--bg-progress-track": "#eee8d5"
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,9 @@ try {
|
||||
const last = JSON.parse(localStorage.getItem("openidea.theme") ?? "null");
|
||||
if (last?.theme) root.dataset.theme = last.theme;
|
||||
if (last?.contrast) root.dataset.contrast = last.contrast;
|
||||
// A built-in palette theme (Solarized, One) over its light / dark base (tokens.css).
|
||||
if (typeof last?.colorTheme === "string" && /^[a-z][a-z0-9-]*$/.test(last.colorTheme))
|
||||
root.dataset.colorTheme = last.colorTheme;
|
||||
// A plugin theme's stylesheet (plugins/bridge.ts), so the workbench doesn't
|
||||
// show the built-in theme until the plugin host answers.
|
||||
const plugin = JSON.parse(localStorage.getItem("openidea.pluginTheme") ?? "null");
|
||||
@@ -21,6 +24,7 @@ try {
|
||||
root.dataset.pluginTheme = plugin.id;
|
||||
root.dataset.pluginThemeKind = root.dataset.theme = plugin.kind === "light" ? "light" : "dark";
|
||||
delete root.dataset.contrast;
|
||||
delete root.dataset.colorTheme;
|
||||
}
|
||||
// The splash's frame, text and accent colours, resolved by theme.ts (splash.css).
|
||||
const colors = [
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
convertIcls,
|
||||
@@ -77,73 +77,6 @@ describe("theme plugin template", () => {
|
||||
});
|
||||
});
|
||||
|
||||
/** Theme packages in plugins/: every theme they contribute, with its editor scheme. */
|
||||
function pluginThemes() {
|
||||
return readdirSync("plugins", { withFileTypes: true })
|
||||
.filter((d) => d.isDirectory() && existsSync(`plugins/${d.name}/plugin.toml`))
|
||||
.flatMap((d) => {
|
||||
const dir = `plugins/${d.name}`;
|
||||
const manifest = read(`${dir}/plugin.toml`);
|
||||
return manifest
|
||||
.split("[[contributes.themes]]")
|
||||
.slice(1)
|
||||
.map((entry) => ({
|
||||
dir,
|
||||
manifest,
|
||||
path: /^path\s*=\s*"([^"]+)"/m.exec(entry)?.[1],
|
||||
scheme: /^editor-scheme\s*=\s*"([^"]+)"/m.exec(entry)?.[1],
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
describe("theme plugins in plugins/", () => {
|
||||
const themes = pluginThemes();
|
||||
|
||||
it("include Solarized and One, light and dark", () => {
|
||||
expect(themes.map((t) => `${t.dir}/${t.path}`)).toEqual(
|
||||
expect.arrayContaining([
|
||||
"plugins/theme-solarized/themes/solarized-light.theme.json",
|
||||
"plugins/theme-solarized/themes/solarized-dark.theme.json",
|
||||
"plugins/theme-one/themes/one-light.theme.json",
|
||||
"plugins/theme-one/themes/one-dark.theme.json",
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
it.each(themes.map((t) => [`${t.dir}/${t.path}`, t] as const))(
|
||||
"%s sets every UI token and its scheme every editor token",
|
||||
(_name, t) => {
|
||||
// A failure here means tokens.css gained (or lost) a themeable token: add it to the theme too.
|
||||
expect(t.path && t.scheme, "theme and editor-scheme paths").toBeTruthy();
|
||||
expect(t.manifest).not.toMatch(/^wasm\s*=/m);
|
||||
const ui = JSON.parse(stripJsonComments(read(`${t.dir}/${t.path}`))) as {
|
||||
id: string;
|
||||
name: string;
|
||||
kind: string;
|
||||
tokens: Record<string, string>;
|
||||
};
|
||||
const ed = JSON.parse(stripJsonComments(read(`${t.dir}/${t.scheme}`))) as { tokens: Record<string, string> };
|
||||
expect(ui.id).toMatch(/^[a-z0-9][a-z0-9._-]*$/);
|
||||
expect(ui.name.trim()).not.toBe("");
|
||||
expect(["light", "dark"]).toContain(ui.kind);
|
||||
expect(sorted(Object.keys(ui.tokens))).toEqual(sorted(sets.ui));
|
||||
expect(sorted(Object.keys(ed.tokens))).toEqual(sorted(sets.scheme));
|
||||
for (const [k, v] of Object.entries({ ...ui.tokens, ...ed.tokens })) {
|
||||
expect(/[;{}<>\\\n]|url\(|image\(/i.test(v), `${k}: ${v}`).toBe(false);
|
||||
// var() may only point at tokens the IDE defines.
|
||||
for (const [, ref] of v.matchAll(/var\((--[a-z0-9-]+)/g)) expect(css, `${k} → ${ref}`).toContain(`${ref}:`);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
it("ship the licence of the palettes they port", () => {
|
||||
for (const dir of new Set(themes.map((t) => t.dir))) {
|
||||
if (dir === "plugins/theme-solarized" || dir === "plugins/theme-one")
|
||||
expect(read(`${dir}/LICENSE`), dir).toContain("MIT License");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("IntelliJ theme import", () => {
|
||||
const themeJson = `{
|
||||
// comment
|
||||
|
||||
@@ -9,6 +9,7 @@ mod logging;
|
||||
mod menu;
|
||||
mod shell_env;
|
||||
mod state;
|
||||
mod theme_frame;
|
||||
mod windows;
|
||||
|
||||
use state::AppState;
|
||||
|
||||
@@ -293,6 +293,7 @@ impl AppState {
|
||||
&bundles,
|
||||
lombok.jar(),
|
||||
);
|
||||
ide_sdk::jdtls::launch_directly(cfg);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
//! Built-in themes' window frame colour (`--bg-frame`), read from the UI's own
|
||||
//! `src/styles/tokens.css` so a native window opens in the colour its page paints.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::sync::LazyLock;
|
||||
use tauri::utils::config::Color;
|
||||
|
||||
const TOKENS_CSS: &str = include_str!("../../src/styles/tokens.css");
|
||||
|
||||
/// A top-level rule: its selector list and custom-property declarations.
|
||||
type Block = (Vec<String>, HashMap<String, String>);
|
||||
|
||||
/// The rule blocks of tokens.css, in source order.
|
||||
static BLOCKS: LazyLock<Vec<Block>> = LazyLock::new(|| blocks(TOKENS_CSS));
|
||||
|
||||
/// `--bg-frame` of built-in theme `id` (`light`, `dark`, `dark-hc` or a palette
|
||||
/// theme with a `:root[data-color-theme="<id>"]` block); `None` for any other id.
|
||||
pub fn builtin_frame(id: &str) -> Option<Color> {
|
||||
builtin_frame_in(&BLOCKS, id)
|
||||
}
|
||||
|
||||
fn builtin_frame_in(blocks: &[Block], id: &str) -> Option<Color> {
|
||||
let palette = format!(":root[data-color-theme=\"{id}\"]");
|
||||
let mut selectors = vec![":root".to_owned()];
|
||||
match id {
|
||||
"dark" => {}
|
||||
"light" => selectors.push(":root[data-theme=\"light\"]".into()),
|
||||
"dark-hc" => selectors.push(":root[data-theme=\"dark-hc\"]".into()),
|
||||
_ if blocks.iter().any(|(sel, _)| sel.contains(&palette)) => {
|
||||
if id.ends_with("light") {
|
||||
selectors.push(":root[data-theme=\"light\"]".into());
|
||||
}
|
||||
selectors.push(":root[data-color-theme]".into());
|
||||
selectors.push(palette);
|
||||
}
|
||||
_ => return None,
|
||||
}
|
||||
// Later matching blocks win, as in the page (the selectors involved share a specificity order).
|
||||
let mut vars: HashMap<&str, &str> = HashMap::new();
|
||||
for (sel, decls) in blocks {
|
||||
if sel.iter().any(|s| selectors.contains(s)) {
|
||||
vars.extend(decls.iter().map(|(k, v)| (k.as_str(), v.as_str())));
|
||||
}
|
||||
}
|
||||
let mut value = *vars.get("--bg-frame")?;
|
||||
for _ in 0..8 {
|
||||
match value.strip_prefix("var(").and_then(|v| v.strip_suffix(')')) {
|
||||
Some(name) => value = vars.get(name.split(',').next()?.trim())?,
|
||||
None => return parse_color(value),
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
fn blocks(css: &str) -> Vec<Block> {
|
||||
let mut text = String::with_capacity(css.len());
|
||||
let mut rest = css;
|
||||
while let Some(start) = rest.find("/*") {
|
||||
text.push_str(&rest[..start]);
|
||||
rest = rest[start + 2..].find("*/").map_or("", |end| &rest[start + 2 + end + 2..]);
|
||||
}
|
||||
text.push_str(rest);
|
||||
|
||||
let mut out = Vec::new();
|
||||
let mut rest = text.as_str();
|
||||
while let Some(open) = rest.find('{') {
|
||||
let selector = rest[..open].trim();
|
||||
// Matching close brace (nested at-rule blocks are skipped whole).
|
||||
let mut depth = 0;
|
||||
let Some(close) = rest[open..].char_indices().find_map(|(i, c)| {
|
||||
match c {
|
||||
'{' => depth += 1,
|
||||
'}' => depth -= 1,
|
||||
_ => {}
|
||||
}
|
||||
(depth == 0).then_some(open + i)
|
||||
}) else {
|
||||
break;
|
||||
};
|
||||
if !selector.starts_with('@') {
|
||||
let decls = rest[open + 1..close]
|
||||
.split(';')
|
||||
.filter_map(|d| d.split_once(':'))
|
||||
.filter(|(k, _)| k.trim().starts_with("--"))
|
||||
.map(|(k, v)| (k.trim().to_owned(), v.trim().to_owned()))
|
||||
.collect();
|
||||
out.push((selector.split(',').map(|s| s.trim().to_owned()).collect(), decls));
|
||||
}
|
||||
rest = &rest[close + 1..];
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// `#hex` or `hsl(h, s%, l%)`, rounded to 8-bit channels as browsers do.
|
||||
fn parse_color(value: &str) -> Option<Color> {
|
||||
if value.starts_with('#') {
|
||||
return serde_json::from_value(serde_json::Value::String(value.to_owned())).ok();
|
||||
}
|
||||
let args = value.strip_prefix("hsl(")?.strip_suffix(')')?;
|
||||
let nums: Vec<f64> = args
|
||||
.split([',', ' '])
|
||||
.filter(|s| !s.is_empty())
|
||||
.map(|s| s.trim_end_matches("deg").trim_end_matches('%').parse())
|
||||
.collect::<Result<_, _>>()
|
||||
.ok()?;
|
||||
let [h, s, l] = nums[..] else { return None };
|
||||
let (s, l) = (s / 100.0, l / 100.0);
|
||||
let c = (1.0 - (2.0 * l - 1.0).abs()) * s;
|
||||
let hp = (h.rem_euclid(360.0)) / 60.0;
|
||||
let x = c * (1.0 - (hp % 2.0 - 1.0).abs());
|
||||
let (r, g, b) = match hp as u8 {
|
||||
0 => (c, x, 0.0),
|
||||
1 => (x, c, 0.0),
|
||||
2 => (0.0, c, x),
|
||||
3 => (0.0, x, c),
|
||||
4 => (x, 0.0, c),
|
||||
_ => (c, 0.0, x),
|
||||
};
|
||||
let m = l - c / 2.0;
|
||||
let byte = |v: f64| ((v + m) * 255.0).round().clamp(0.0, 255.0) as u8;
|
||||
Some(Color(byte(r), byte(g), byte(b), 0xff))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn reads_every_builtin_frame_from_tokens_css() {
|
||||
for (id, color) in [
|
||||
("light", Color(0xe9, 0xea, 0xee, 0xff)),
|
||||
("dark", Color(0x26, 0x28, 0x2c, 0xff)),
|
||||
("dark-hc", Color(0x1a, 0x1b, 0x1e, 0xff)),
|
||||
("solarized-light", Color(0xee, 0xe8, 0xd5, 0xff)),
|
||||
("solarized-dark", Color(0x07, 0x36, 0x42, 0xff)),
|
||||
("one-light", Color(0xea, 0xea, 0xeb, 0xff)),
|
||||
("one-dark", Color(0x21, 0x25, 0x2b, 0xff)),
|
||||
] {
|
||||
assert_eq!(builtin_frame(id), Some(color), "{id}");
|
||||
}
|
||||
assert_eq!(builtin_frame("system"), None);
|
||||
assert_eq!(builtin_frame("nope"), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resolves_var_chains_and_hsl() {
|
||||
let css = r#"
|
||||
/* a { comment } */
|
||||
:root { --bg-frame: #000; --p: hsl(0, 100%, 50%); }
|
||||
@media (x) { :root { --bg-frame: #fff; } }
|
||||
:root[data-color-theme] { --bg-frame: var(--q); }
|
||||
:root[data-color-theme="t-dark"] { --q: var(--p, #123); }
|
||||
"#;
|
||||
let b = blocks(css);
|
||||
assert_eq!(builtin_frame_in(&b, "dark"), Some(Color(0, 0, 0, 0xff)));
|
||||
assert_eq!(builtin_frame_in(&b, "t-dark"), Some(Color(0xff, 0, 0, 0xff)));
|
||||
assert_eq!(builtin_frame_in(&b, "u-dark"), None);
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
//! [`Launch::settings_page`] tells it which page to show.
|
||||
|
||||
use crate::state::AppState;
|
||||
use crate::theme_frame::builtin_frame;
|
||||
use ide_core::settings::AppearanceSettings;
|
||||
use ide_core::{IdeError, IdeResult};
|
||||
use parking_lot::Mutex;
|
||||
@@ -212,22 +213,15 @@ fn window_config(app: &AppHandle) -> IdeResult<WindowConfig> {
|
||||
|
||||
/// The theme's `--bg-frame` (tokens.css), mirroring `resolveThemeId` in theme.ts.
|
||||
pub fn frame_color(appearance: &AppearanceSettings, os_dark: bool) -> Color {
|
||||
const LIGHT: Color = Color(0xe9, 0xea, 0xee, 0xff);
|
||||
const DARK: Color = Color(0x26, 0x28, 0x2c, 0xff);
|
||||
const DARK_HC: Color = Color(0x1a, 0x1b, 0x1e, 0xff);
|
||||
let sync = appearance.sync_with_os || appearance.theme == "system";
|
||||
let theme = match (sync, os_dark) {
|
||||
(false, _) => &appearance.theme,
|
||||
(true, true) => &appearance.preferred_dark_theme,
|
||||
(true, false) => &appearance.preferred_light_theme,
|
||||
};
|
||||
match theme.as_str() {
|
||||
"dark-hc" => DARK_HC,
|
||||
"dark" => DARK,
|
||||
"light" => LIGHT,
|
||||
_ if sync && os_dark => DARK,
|
||||
_ => LIGHT,
|
||||
}
|
||||
builtin_frame(theme)
|
||||
.or_else(|| builtin_frame(if sync && os_dark { "dark" } else { "light" }))
|
||||
.unwrap_or(Color(0xe9, 0xea, 0xee, 0xff))
|
||||
}
|
||||
|
||||
/// A `#rgb` / `#rrggbb` / `#rrggbbaa` colour sent by the UI (Tauri's own parser).
|
||||
@@ -475,6 +469,25 @@ mod tests {
|
||||
assert_eq!(frame_color(&a, true), Color(0x26, 0x28, 0x2c, 0xff));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn additional_palettes_keep_native_startup_and_os_preferences_in_sync() {
|
||||
for (id, color) in [
|
||||
("solarized-light", Color(0xee, 0xe8, 0xd5, 0xff)),
|
||||
("solarized-dark", Color(0x07, 0x36, 0x42, 0xff)),
|
||||
("one-light", Color(0xea, 0xea, 0xeb, 0xff)),
|
||||
("one-dark", Color(0x21, 0x25, 0x2b, 0xff)),
|
||||
] {
|
||||
let mut a = AppearanceSettings { theme: id.into(), ..Default::default() };
|
||||
assert_eq!(frame_color(&a, false), color);
|
||||
assert_eq!(frame_color(&a, true), color);
|
||||
a.sync_with_os = true;
|
||||
a.preferred_light_theme = id.into();
|
||||
a.preferred_dark_theme = id.into();
|
||||
assert_eq!(frame_color(&a, false), color);
|
||||
assert_eq!(frame_color(&a, true), color);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn frame_colours_from_the_ui_parse_as_hex() {
|
||||
for (hex, expected) in [
|
||||
|
||||
@@ -54,6 +54,7 @@ import {
|
||||
} from "./cm/structural";
|
||||
import type { DocModel } from "./model/document";
|
||||
import { structure } from "@/editor/structure";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
/** Text-editing actions: the editor has focus, or a popup (Find Action) runs them on it. */
|
||||
export const TEXT_WHEN = "editorTextFocus || textEditorActive && popupOpen";
|
||||
@@ -293,7 +294,7 @@ function copyReference(view: EditorView, slot: EditorSlot) {
|
||||
});
|
||||
recordClipboard(reference);
|
||||
void navigator.clipboard?.writeText(reference).catch(() => {});
|
||||
void executeAction("editor.showHint", { text: `Copied reference: ${reference}` });
|
||||
void executeAction("editor.showHint", { text: tx`Copied reference: ${reference}` });
|
||||
}
|
||||
|
||||
/** ⌃G; when nothing more is found, a hint first and the search from the top on the next press (IDEA). */
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
import { EditorView } from "@codemirror/view";
|
||||
import type { EditorState } from "@codemirror/state";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
export const MAX_CLIPBOARD_ENTRIES = 30;
|
||||
|
||||
@@ -45,7 +46,7 @@ export function clipLabel(text: string, max = 80): { label: string; detail: stri
|
||||
const first = (lines.find((l) => l.trim()) ?? "").trim();
|
||||
const label = first.length > max ? `${first.slice(0, max - 1)}…` : first || "(whitespace)";
|
||||
const count = text.endsWith("\n") ? lines.length - 1 : lines.length;
|
||||
return { label, detail: count > 1 ? `${count} lines` : undefined };
|
||||
return { label, detail: count > 1 ? tx`${count} lines` : undefined };
|
||||
}
|
||||
|
||||
export const clipboardHistoryExtension = EditorView.domEventHandlers({
|
||||
|
||||
@@ -12,6 +12,7 @@ import { openideaHighlightStyle } from "./highlight";
|
||||
import { openideaTheme } from "./theme";
|
||||
import { findLanguageDescription, loadSupport, loadedSupport, uiModeForPath } from "./languages";
|
||||
import { fontExtension } from "./setup";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
export async function previewExtensions(path: string, settings: EditorSettings | undefined): Promise<Extension> {
|
||||
const open = editorsFor(path)[0]?.ctx;
|
||||
@@ -25,7 +26,7 @@ export async function previewExtensions(path: string, settings: EditorSettings |
|
||||
syntaxHighlighting(openideaHighlightStyle),
|
||||
EditorState.readOnly.of(true),
|
||||
EditorView.editable.of(false),
|
||||
EditorView.contentAttributes.of({ "aria-label": `Preview of ${path}` }),
|
||||
EditorView.contentAttributes.of({ "aria-label": tx`Preview of ${path}` }),
|
||||
support ?? [],
|
||||
];
|
||||
}
|
||||
@@ -51,6 +51,7 @@ import { gutterLineDrag } from "./gutterDrag";
|
||||
import { overwriteField } from "./overwrite";
|
||||
import { clipboardHistoryExtension } from "../clipboardHistory";
|
||||
import type { LanguageInfo } from "../backend";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
export const compartments = {
|
||||
language: new Compartment(),
|
||||
@@ -309,7 +310,7 @@ export function baseExtensions(o: SetupOptions): Extension {
|
||||
findExtension(),
|
||||
overviewLane,
|
||||
codeLensExtension,
|
||||
EditorView.contentAttributes.of({ spellcheck: "false", autocorrect: "off", autocapitalize: "off", "aria-label": `Editor for ${o.ctx.path}` }),
|
||||
EditorView.contentAttributes.of({ spellcheck: "false", autocorrect: "off", autocapitalize: "off", "aria-label": tx`Editor for ${o.ctx.path}` }),
|
||||
tabKeymap,
|
||||
keymap.of([...closeBracketsKeymap, ...editorBaseKeymap, indentWithTab]),
|
||||
compartments.language.of(o.language ?? []),
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* every language with a grammar is covered.
|
||||
*/
|
||||
import type { Text } from "@codemirror/state";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
export interface ChainNode {
|
||||
kind: string;
|
||||
@@ -133,7 +134,7 @@ export function unwrapOptions(doc: Text, chain: readonly ChainNode[]): UnwrapOpt
|
||||
const key = `${target.from}:${target.to}:${label}`;
|
||||
if (seen.has(key)) continue;
|
||||
seen.add(key);
|
||||
out.push({ label: `Unwrap '${label}'`, target: { from: target.from, to: target.to }, ...replacement(doc, target, child) });
|
||||
out.push({ label: tx`Unwrap '${label}'`, target: { from: target.from, to: target.to }, ...replacement(doc, target, child) });
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -28,7 +28,7 @@ export function installColorScheme(): () => void {
|
||||
const observer = typeof MutationObserver !== "undefined" ? new MutationObserver(apply) : null;
|
||||
observer?.observe(document.documentElement, {
|
||||
attributes: true,
|
||||
attributeFilter: ["data-theme", "data-contrast", "data-plugin-theme"],
|
||||
attributeFilter: ["data-theme", "data-contrast", "data-color-theme", "data-plugin-theme"],
|
||||
});
|
||||
return () => {
|
||||
unsubscribe();
|
||||
|
||||
@@ -8,11 +8,12 @@ import { basename } from "@/platform/project";
|
||||
import { notifications } from "@/workbench/contributions";
|
||||
import { confirm } from "@/workbench/messages";
|
||||
import type { DocModel } from "./model/document";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
export function readOnlyQuestion(name: string, readOnly: boolean) {
|
||||
return readOnly
|
||||
? { title: "Make File Writable", message: `'${name}' is read-only. Make it writable?`, confirm: "Make Writable" }
|
||||
: { title: "Make File Read-only", message: `Make '${name}' read-only?`, confirm: "Make Read-only" };
|
||||
? { title: "Make File Writable", message: tx`'${name}' is read-only. Make it writable?`, confirm: "Make Writable" }
|
||||
: { title: "Make File Read-only", message: tx`Make '${name}' read-only?`, confirm: "Make Read-only" };
|
||||
}
|
||||
|
||||
/** Applies the toggle without asking. Returns the new read-only state, or null on failure. */
|
||||
|
||||
@@ -44,6 +44,7 @@ import {
|
||||
} from "../cm/setup";
|
||||
import { setMethodLines, softWrapActive } from "../cm/prefs";
|
||||
import type { EditorSlot } from "./slot";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
export type Banner = "binary" | "tooLarge" | "readOnly" | "library" | null;
|
||||
|
||||
@@ -237,7 +238,7 @@ export class DocModel {
|
||||
manager.notify({
|
||||
level: "warning",
|
||||
title: "Editor resynchronised",
|
||||
body: `Some unsaved edits to ${this.path} could not be applied and were replaced by the file's current content.`,
|
||||
body: tx`Some unsaved edits to ${this.path} could not be applied and were replaced by the file's current content.`,
|
||||
}),
|
||||
onError: (e) => console.warn(`document ${this.path}: sync error`, e),
|
||||
},
|
||||
|
||||
@@ -44,6 +44,7 @@ import { FindBar } from "./FindBar";
|
||||
import { EditorBanners, VirtualBanner } from "./Banner";
|
||||
import { CodeBreadcrumbs } from "./StatusItems";
|
||||
import styles from "./EditorArea.module.css";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
export function EditorAreaView() {
|
||||
const layout = useTabs((s) => s.layout);
|
||||
@@ -343,7 +344,7 @@ function PaneContent({ paneId, tab }: { paneId: string; tab: Tab }) {
|
||||
);
|
||||
}
|
||||
const kind = kinds.get(tab.input.kind);
|
||||
if (!kind) return <EmptyState icon="file" title={`No editor for “${tab.input.kind}”`} />;
|
||||
if (!kind) return <EmptyState icon="file" title={tx`No editor for “${tab.input.kind}”`} />;
|
||||
const Component = kind.component;
|
||||
return (
|
||||
<div className={styles.kind} data-editor-focus="" tabIndex={-1} key={tab.id}>
|
||||
|
||||
@@ -16,6 +16,7 @@ import { posToOffset } from "./positions";
|
||||
import { onLspRefresh, serverBackoff } from "./availability";
|
||||
import { editorPrefs } from "@/platform/editorSettings";
|
||||
import { authorLabel, authorSummary, authorTooltip, blameFor, onBlameInvalidated } from "./authorLens";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
const LENS_KINDS = new Set<SymbolKind>([
|
||||
"class",
|
||||
@@ -190,7 +191,7 @@ class UsagesLensPlugin {
|
||||
lenses.push({
|
||||
pos: offset,
|
||||
title: usagesLabel(n),
|
||||
tooltip: n ? `Show usages of ${t.name}` : undefined,
|
||||
tooltip: n ? tx`Show usages of ${t.name}` : undefined,
|
||||
order: 10,
|
||||
run: n ? (v) => openUsages(v, Math.min(offset, v.state.doc.length)) : undefined,
|
||||
});
|
||||
|
||||
@@ -14,6 +14,7 @@ import { call, commands, isTauri, onIdeEvent, type PathCompletion } from "@/plat
|
||||
import { fileIconName, folderIconName } from "@/ui";
|
||||
import { setFileDiagnostics } from "./diagnostics";
|
||||
import { docOf, lspDoc } from "./lsp";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
// --- completion ---------------------------------------------------------------
|
||||
|
||||
@@ -118,7 +119,7 @@ export function unresolvedReferences(): Extension {
|
||||
refs.map((r) => ({
|
||||
range: r.range,
|
||||
severity: "warning",
|
||||
message: `Cannot resolve file '${r.value}'`,
|
||||
message: tx`Cannot resolve file '${r.value}'`,
|
||||
source: doc.language === "html" || doc.language === "vue" || doc.language === "svelte" ? "HTML" : "CSS",
|
||||
code: null,
|
||||
})),
|
||||
|
||||
@@ -161,7 +161,7 @@ export async function reformatDialog(
|
||||
const name = ctx.path.slice(ctx.path.lastIndexOf("/") + 1);
|
||||
openPopup({
|
||||
kind: "reformat",
|
||||
title: `Reformat File: ${name}`,
|
||||
title: tx`Reformat File: ${name}`,
|
||||
hasSelection: !sel.empty,
|
||||
canOptimizeImports: !contributedAt(view.state, CONTRIBUTED_FORMAT, 0),
|
||||
initial: lastOptions,
|
||||
|
||||
@@ -17,6 +17,7 @@ import { debounce, docOf, isUnavailable, lspRequest } from "./lsp";
|
||||
import { offsetsToRange, posToOffset } from "./positions";
|
||||
import { onLspRefresh, serverBackoff } from "./availability";
|
||||
import { gotoTargets } from "./navigation";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
const KIND_LABEL: Record<InlayHint["kind"], string> = {
|
||||
type: "Type hints",
|
||||
@@ -39,7 +40,7 @@ function typeHintOffset(view: EditorView, at: number): number | null {
|
||||
/** Right-click on a hint: turn its kind off (IDEA's "Disable '…' hints"), or open the settings. */
|
||||
export function inlayMenuItems(kind: InlayHint["kind"]): MenuItem[] {
|
||||
return [
|
||||
{ label: `Disable ${KIND_LABEL[kind]}`, run: () => void setEditorSetting(`inlay.${kind}`, false) },
|
||||
{ label: tx`Disable ${KIND_LABEL[kind]}`, run: () => void setEditorSetting(`inlay.${kind}`, false) },
|
||||
{ kind: "separator" },
|
||||
{ label: "Inlay Hints Settings…", run: () => void executeAction("file.settings", "editor.inlayHints") },
|
||||
];
|
||||
|
||||
@@ -21,6 +21,7 @@ import { spellingIntentions } from "./spelling";
|
||||
import { inspectionsAt } from "./diagnostics";
|
||||
import { SPELLING_INSPECTION } from "@/platform/inspections";
|
||||
import { editInspectionSettings, intentionControls } from "@/platform/inspectionControls";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
const isQuickFix = (a: CodeAction) => !!a.kind && (a.kind === "quickfix" || a.kind.startsWith("quickfix."));
|
||||
|
||||
@@ -195,7 +196,7 @@ export function withInspectionControls(view: EditorView, items: ListPopupItem[])
|
||||
...items,
|
||||
...inspections.map((inspection) => ({
|
||||
id: `inspection:${inspection.id}`,
|
||||
label: `Inspection '${inspection.name}' options`,
|
||||
label: tx`Inspection '${inspection.name}' options`,
|
||||
icon: "settings",
|
||||
run: () => editInspectionSettings(inspection.id),
|
||||
submenu: intentionControls(inspection),
|
||||
|
||||
@@ -52,6 +52,7 @@ import { isVirtualUri, virtualContainer } from "@/platform/virtualDocs";
|
||||
import { shortcutLabel } from "@/platform/keymap";
|
||||
import { isNavigationGesture, onNavigationModifier } from "@/platform/navigationModifier";
|
||||
import { create } from "zustand";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
export async function navigateTo(loc: Location) {
|
||||
await editorService().openFile(loc.path, {
|
||||
@@ -224,7 +225,7 @@ async function gotoWebReference(view: EditorView, doc: EditorDocContext, pos: Po
|
||||
openPopup({
|
||||
kind: "list",
|
||||
anchor: caretAnchor(view, offset),
|
||||
title: `Choose Declaration of '${label}' (${targets.length} found)`,
|
||||
title: tx`Choose Declaration of '${label}' (${targets.length} found)`,
|
||||
items: await locationItems(targets),
|
||||
pin: pinToFind(label, targets),
|
||||
});
|
||||
|
||||
@@ -29,6 +29,7 @@ import {
|
||||
renameRisks,
|
||||
type LocalRenamePlan,
|
||||
} from "./syntaxFallback";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
async function applyEdit(view: EditorView, edit: WorkspaceEdit) {
|
||||
try {
|
||||
@@ -83,7 +84,7 @@ export async function startRename(view: EditorView) {
|
||||
openPopup({
|
||||
kind: "rename",
|
||||
anchor: caretAnchor(view, from),
|
||||
title: `Rename '${oldName}'`,
|
||||
title: tx`Rename '${oldName}'`,
|
||||
initial,
|
||||
onSubmit: (newName) => void finishRename(view, doc, pos, oldName, newName),
|
||||
});
|
||||
@@ -99,7 +100,7 @@ export async function startRename(view: EditorView) {
|
||||
startInplaceRename(view, {
|
||||
primary: { from, to },
|
||||
others,
|
||||
hint: keys ? `Press ${keys} to show dialog with more options` : "Rename in place: ↵ to finish, Esc to cancel",
|
||||
hint: keys ? tx`Press ${keys} to show dialog with more options` : "Rename in place: ↵ to finish, Esc to cancel",
|
||||
commit: (newName) => void commitInplace(view, doc, pos, oldName, newName),
|
||||
dialog,
|
||||
});
|
||||
@@ -223,7 +224,7 @@ async function finishRename(view: EditorView, doc: EditorDocContext, pos: Pos, o
|
||||
}
|
||||
openPopup({
|
||||
kind: "preview",
|
||||
title: `Rename '${oldName}' to '${newName}'`,
|
||||
title: tx`Rename '${oldName}' to '${newName}'`,
|
||||
summary,
|
||||
confirmLabel: "Do Refactor",
|
||||
onConfirm: () => void applyEdit(view, edit),
|
||||
@@ -265,7 +266,7 @@ async function startSyntaxRename(view: EditorView, doc: EditorDocContext, pos: P
|
||||
openPopup({
|
||||
kind: "rename",
|
||||
anchor: caretAnchor(view, rangeToOffsets(view.state.doc, (at ?? plan.occurrences[0]!).range).from),
|
||||
title: `Rename '${plan.symbol.name}'`,
|
||||
title: tx`Rename '${plan.symbol.name}'`,
|
||||
initial: plan.symbol.name,
|
||||
note: `${SYNTAX_NOTE}: local occurrences only`,
|
||||
onSubmit: (newName) => void commitSyntaxRename(view, doc, plan, newName),
|
||||
@@ -315,7 +316,7 @@ export async function commitSyntaxRename(view: EditorView, doc: EditorDocContext
|
||||
});
|
||||
openPopup({
|
||||
kind: "preview",
|
||||
title: `Rename '${oldName}' to '${newName}'`,
|
||||
title: tx`Rename '${oldName}' to '${newName}'`,
|
||||
summary: {
|
||||
files: 1,
|
||||
occurrences: occurrences.length,
|
||||
|
||||
@@ -27,6 +27,7 @@ import { rangeToOffsets } from "./positions";
|
||||
import { showHint } from "./hint";
|
||||
import { caretAnchor, openPopup, type ListPopupItem } from "./popupStore";
|
||||
import { renameNamePart } from "./rename";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
const CHECK_DELAY = 800;
|
||||
|
||||
@@ -124,7 +125,7 @@ async function changeTo(view: EditorView, typo: PlacedTypo) {
|
||||
openPopup({
|
||||
kind: "list",
|
||||
anchor: caretAnchor(view, typo.from),
|
||||
title: `${rename ? "Rename" : "Change"} '${typo.word}' to`,
|
||||
title: rename ? tx`Rename '${typo.word}' to` : tx`Change '${typo.word}' to`,
|
||||
items: suggestions.map((s, i) => ({ id: `${i}`, label: s, run: () => applyCorrection(view, typo, s) })),
|
||||
});
|
||||
}
|
||||
@@ -142,7 +143,7 @@ export function spellingIntentions(view: EditorView): ListPopupItem[] {
|
||||
? [
|
||||
{
|
||||
id: "spelling.saveProject",
|
||||
label: `Save '${typo.word}' to project-level dictionary`,
|
||||
label: tx`Save '${typo.word}' to project-level dictionary`,
|
||||
icon: "bulb-fix",
|
||||
run: () => saveToDictionary(typo.word, "project"),
|
||||
},
|
||||
@@ -150,7 +151,7 @@ export function spellingIntentions(view: EditorView): ListPopupItem[] {
|
||||
: []),
|
||||
{
|
||||
id: "spelling.saveIde",
|
||||
label: `Save '${typo.word}' to application-level dictionary`,
|
||||
label: tx`Save '${typo.word}' to application-level dictionary`,
|
||||
icon: "bulb-fix",
|
||||
run: () => saveToDictionary(typo.word, "ide"),
|
||||
},
|
||||
@@ -210,7 +211,7 @@ export function spellingExtension(): Extension {
|
||||
typos.map((t) => ({
|
||||
range: t.range,
|
||||
severity: "info",
|
||||
message: `Typo: In word '${t.word}'`,
|
||||
message: tx`Typo: In word '${t.word}'`,
|
||||
source: "Spelling",
|
||||
code: null,
|
||||
})),
|
||||
|
||||
@@ -9,6 +9,7 @@ import type { Location, Pos, Range, SymbolKind, SymbolMatch } from "@/bindings";
|
||||
import { call, commands } from "@/platform/ipc";
|
||||
import { structure, type Locals, type LocalSymbol, type NodeAt } from "@/editor/structure";
|
||||
import { comparePos, rangeContains, rangeToOffsets } from "./positions";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
/** Subtle marker for answers that did not come from the language server. */
|
||||
export const SYNTAX_NOTE = "Based on syntax (language server not ready)";
|
||||
@@ -237,7 +238,7 @@ export async function planLocalRename(
|
||||
if (locals.status === "notLocal")
|
||||
return {
|
||||
kind: "refused",
|
||||
message: `Can't rename '${locals.name}' without the language server: only local variables can be renamed based on syntax`,
|
||||
message: tx`Can't rename '${locals.name}' without the language server: only local variables can be renamed based on syntax`,
|
||||
};
|
||||
const { symbol } = locals;
|
||||
const ranges = [symbol.definition, ...symbol.references].sort((a, b) => comparePos(a.start, b.start));
|
||||
|
||||
@@ -20,6 +20,7 @@ import { editorService } from "@/workbench/contributions";
|
||||
import { fileIconName } from "@/ui";
|
||||
import { gotoTestOrSubject, type TestNavDeps } from "./gotoTest";
|
||||
import { baseName, memberAt, methodStop, superMethods } from "./structureNav";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
const EDITOR_WHEN = "textEditorActive && (editorFocus || popupOpen || !toolWindowFocus)";
|
||||
|
||||
@@ -97,7 +98,7 @@ async function superMethod(view: EditorView) {
|
||||
openPopup({
|
||||
kind: "list",
|
||||
anchor: caretAnchor(view, head),
|
||||
title: method ? `Choose Super Method of ${baseName(method.name)} (${locs.length} found)` : `Choose Super Class or Interface (${locs.length} found)`,
|
||||
title: method ? tx`Choose Super Method of ${baseName(method.name)} (${locs.length} found)` : tx`Choose Super Class or Interface (${locs.length} found)`,
|
||||
items: await locationItems(locs),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import {
|
||||
type DeclResult,
|
||||
type Declaration,
|
||||
} from "./templates";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
/** Why the language server could not do it (see `withFallback`). */
|
||||
export type FallbackReason = "notReady" | "error" | "empty";
|
||||
@@ -594,7 +595,7 @@ async function chooseOccurrences(p: Prepared, self: Occurrence, others: Occurren
|
||||
},
|
||||
{
|
||||
id: "all",
|
||||
label: `Replace all ${others.length + 1} occurrences`,
|
||||
label: tx`Replace all ${others.length + 1} occurrences`,
|
||||
onActive: () => highlightRanges(view, [self, ...others]),
|
||||
run: () => apply(true),
|
||||
},
|
||||
@@ -663,7 +664,7 @@ function applyAndName(p: Prepared, plan: Plan, names: string[]) {
|
||||
initial: name,
|
||||
suggestions: names,
|
||||
note: NOTES[p.reason],
|
||||
hint: `↵ Apply · Esc Keep '${name}'`,
|
||||
hint: tx`↵ Apply · Esc Keep '${name}'`,
|
||||
onSubmit: (chosen) => void rename(p, chosen, name, { original, applied, plan, ranges }),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ describe("safeDelete in the editor", () => {
|
||||
expect((await run("delete")).state.doc.toString()).toBe("fn unused() {\n unused();\n}\n\nfn main() {}\n");
|
||||
});
|
||||
|
||||
it("confirms first ('Delete function …?') and searches nothing when cancelled", async () => {
|
||||
it("confirms first ('Delete Function …?') and searches nothing when cancelled", async () => {
|
||||
const v = editor(text, "unused() {");
|
||||
outline = ok([item(text, "unused", "fn unused() {\n unused();\n}")]);
|
||||
confirmAnswer = null;
|
||||
@@ -272,7 +272,7 @@ describe("safeDelete in the editor", () => {
|
||||
expect(confirmChecked).toHaveBeenCalledTimes(1);
|
||||
const opts = confirmChecked.mock.calls[0]![0];
|
||||
expect(opts.title).toBe("Safe Delete");
|
||||
expect(opts.message).toBe("Delete function 'unused'?");
|
||||
expect(opts.message).toBe("Delete Function 'unused'?");
|
||||
expect(opts.checkbox).toBe("Search in comments and strings");
|
||||
expect(lspReferences).not.toHaveBeenCalled();
|
||||
expect(v.state.doc.toString()).toBe(text);
|
||||
|
||||
@@ -25,6 +25,7 @@ import { ask, confirmChecked } from "@/workbench/messages";
|
||||
import { openPopup, type PreviewOccurrence } from "@/editor/lsp/popupStore";
|
||||
import { cannotPerform } from "./catalog";
|
||||
import { cancelled, languageName } from "./query";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Deletion range (pure)
|
||||
@@ -269,11 +270,19 @@ export function usagesMessage(
|
||||
): { message: string; detail: string } {
|
||||
const n = usages.length;
|
||||
const files = new Set(usages.map((u) => u.path)).size;
|
||||
const noun = n === 1 ? "usage that is" : "usages that are";
|
||||
return {
|
||||
message: `${n} ${n === 1 ? "usage" : "usages"} found`,
|
||||
detail: `${subject} ${plural ? "have" : "has"} ${n} ${noun} not safe to delete${files > 1 ? ` (in ${files} files)` : ""}.`,
|
||||
};
|
||||
const where = files > 1 ? tx` (in ${files} files)` : "";
|
||||
let detail: string;
|
||||
if (plural)
|
||||
detail =
|
||||
n === 1
|
||||
? tx`${subject} have ${n} usage that is not safe to delete${where}.`
|
||||
: tx`${subject} have ${n} usages that are not safe to delete${where}.`;
|
||||
else
|
||||
detail =
|
||||
n === 1
|
||||
? tx`${subject} has ${n} usage that is not safe to delete${where}.`
|
||||
: tx`${subject} has ${n} usages that are not safe to delete${where}.`;
|
||||
return { message: n === 1 ? tx`${n} usage found` : tx`${n} usages found`, detail };
|
||||
}
|
||||
|
||||
/** IDEA's "Usages Detected" question; resolves "cancel" when dismissed. */
|
||||
@@ -391,7 +400,7 @@ function previewTextOccurrences(
|
||||
});
|
||||
openPopup({
|
||||
kind: "preview",
|
||||
title: `Safe Delete ${target.kind.toLowerCase()} '${target.name}'`,
|
||||
title: tx`Safe Delete ${target.kind} '${target.name}'`,
|
||||
summary: {
|
||||
files: 1,
|
||||
occurrences: occurrences.length,
|
||||
@@ -436,7 +445,7 @@ export async function safeDelete(view: EditorView): Promise<void> {
|
||||
// IDEA always confirms first; usages are searched after OK.
|
||||
const confirmed = await confirmChecked({
|
||||
title: "Safe Delete",
|
||||
message: `Delete ${target.kind.toLowerCase()} '${target.name}'?`,
|
||||
message: tx`Delete ${target.kind} '${target.name}'?`,
|
||||
ok: "OK",
|
||||
checkbox: "Search in comments and strings",
|
||||
checked: searchInComments,
|
||||
@@ -453,7 +462,7 @@ export async function safeDelete(view: EditorView): Promise<void> {
|
||||
]);
|
||||
if (view.state.doc !== docBefore) return;
|
||||
if (usages.length) {
|
||||
const answer = await askUsagesDetected(`${target.kind} '${target.name}'`, usages);
|
||||
const answer = await askUsagesDetected(tx`${target.kind} '${target.name}'`, usages);
|
||||
if (answer === "view") viewUsages(target.name, usages);
|
||||
else if (answer === "delete") applyDeletion(view, docBefore, target, comments);
|
||||
else view.focus();
|
||||
|
||||
@@ -27,6 +27,7 @@ import type { RefactoringId } from "./catalog";
|
||||
import { expressionCandidates, expressionPreview } from "./introduce";
|
||||
import { findTextOccurrences } from "./occurrences";
|
||||
import { isIdentifier, isKeyword, suggestNames, uniqueNames } from "./names";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
/** Refactorings that take an expression (chosen first when nothing is selected). */
|
||||
export const EXPRESSION_REFACTORINGS: ReadonlySet<RefactoringId> = new Set([
|
||||
@@ -135,7 +136,7 @@ export function chooseOccurrences(view: EditorView, actions: readonly CodeAction
|
||||
},
|
||||
{
|
||||
id: "all",
|
||||
label: n > 1 ? `Replace all ${n} occurrences` : "Replace all occurrences",
|
||||
label: n > 1 ? tx`Replace all ${n} occurrences` : "Replace all occurrences",
|
||||
onActive: () => highlightRanges(view, n ? occurrences : [{ from: sel.from, to: sel.to }]),
|
||||
run: () => applyIntroduceAction(view, variants.all, id),
|
||||
},
|
||||
@@ -291,13 +292,13 @@ export async function applyIntroduceAction(view: EditorView, action: CodeAction,
|
||||
primary,
|
||||
others,
|
||||
suggestions: names.length > 1 ? names : undefined,
|
||||
hint: keys ? `Press ${keys} to show dialog with more options` : "↵ to finish, Esc to keep the name",
|
||||
hint: keys ? tx`Press ${keys} to show dialog with more options` : "↵ to finish, Esc to keep the name",
|
||||
commit: (name) => renameIntroduced(view, [primary, ...others], found.name, name),
|
||||
dialog: (typed) =>
|
||||
openPopup({
|
||||
kind: "rename",
|
||||
anchor: caretAnchor(view, primary.from),
|
||||
title: `Rename '${found.name}'`,
|
||||
title: tx`Rename '${found.name}'`,
|
||||
initial: typed,
|
||||
suggestions: names,
|
||||
onSubmit: (name) => renameIntroduced(view, [primary, ...others], found.name, name),
|
||||
|
||||
@@ -7,6 +7,7 @@ import { Icon, IconButton, Spinner, T, Tree, showContextMenu, type MenuItem } fr
|
||||
import { age, branchLabel, groupTasks, isBusy, type TaskGroup } from "./model";
|
||||
import { archiveTask, deleteTask, openHome, openTask, useAgents } from "./store";
|
||||
import styles from "./Agents.module.css";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
export function AgentsHeaderActions() {
|
||||
return <IconButton icon="plus" action="agents.newTask" size="small" />;
|
||||
@@ -117,8 +118,8 @@ async function confirmDelete(task: AgentTask) {
|
||||
const r = await confirmChecked({
|
||||
title: "Delete Agent Task",
|
||||
message: worktree
|
||||
? `Delete “${task.title}”? Its branch ${task.branch ?? ""} is kept.`
|
||||
: `Delete “${task.title}”? Files it changed are kept.`,
|
||||
? tx`Delete “${task.title}”? Its branch ${task.branch ?? ""} is kept.`
|
||||
: tx`Delete “${task.title}”? Files it changed are kept.`,
|
||||
ok: "Delete",
|
||||
icon: "warning",
|
||||
checkbox: worktree ? "Also remove its worktree folder" : undefined,
|
||||
|
||||
@@ -157,7 +157,7 @@ export function Composer(props: ComposerProps) {
|
||||
for (const file of picked) {
|
||||
if (!file.type.startsWith("image/")) continue;
|
||||
if (file.size > MAX_IMAGE_BYTES) {
|
||||
notifications().notify({ level: "warning", title: "Image too large", body: `${file.name} is over 5 MB.` });
|
||||
notifications().notify({ level: "warning", title: "Image too large", body: tx`${file.name} is over 5 MB.` });
|
||||
continue;
|
||||
}
|
||||
const reader = new FileReader();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/** Pure composer helpers: `@` / `/` completion, attachments, history recall, settings. */
|
||||
import type { AgentCommand, AgentConfigOption, AgentImage, AgentPrompt, AgentUsage } from "@/bindings";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
export interface FileRef {
|
||||
/** Absolute path (in the task's directory). */
|
||||
@@ -114,7 +115,7 @@ export function usageLabel(u: AgentUsage): { short: string; detail: string } {
|
||||
const pct = Math.min(100, Math.round((u.used / u.size) * 100));
|
||||
const k = (n: number) => (n >= 1000 ? `${Math.round(n / 1000)}k` : `${Math.round(n)}`);
|
||||
const cost = u.cost != null ? ` · ${u.currency === "USD" || !u.currency ? "$" : `${u.currency} `}${u.cost.toFixed(2)}` : "";
|
||||
return { short: `${pct}%`, detail: `${k(u.used)} / ${k(u.size)} tokens${cost}` };
|
||||
return { short: `${pct}%`, detail: tx`${k(u.used)} / ${k(u.size)} tokens${cost}` };
|
||||
}
|
||||
|
||||
/** `data:image/png;base64,AAA` → an image attachment. */
|
||||
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
type StructuralForm,
|
||||
} from "./structural";
|
||||
import styles from "./Analysis.module.css";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
function InspectCodeDialog({ onClose }: { onClose: () => void }) {
|
||||
const [scope, setScope] = useState<ScopeChoice>(() => defaultScope());
|
||||
@@ -363,7 +364,7 @@ function ReplacePreviewDialog({ files, onClose }: { files: StructuralFile[]; onC
|
||||
<Checkbox
|
||||
checked={!excluded.has(key)}
|
||||
onChange={(on) => toggle(key, on)}
|
||||
aria-label={`Replace in ${f.relPath}:${m.range.start.line + 1}`}
|
||||
aria-label={tx`Replace in ${f.relPath}:${m.range.start.line + 1}`}
|
||||
/>
|
||||
<div className={styles.previewBody}>
|
||||
<span className={styles.previewWhere}>
|
||||
|
||||
@@ -11,6 +11,7 @@ import { maybeEditorService, notifications } from "@/workbench/contributions";
|
||||
import { confirm } from "@/workbench/messages";
|
||||
import { removeTask, upsertTask } from "@/workbench/tasks";
|
||||
import { changedFiles, currentFile, type ScopeChoice } from "./scope";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
export interface CleanupOptions {
|
||||
fixAll: boolean;
|
||||
@@ -97,7 +98,7 @@ export async function runCodeCleanup(choice: ScopeChoice, options: CleanupOption
|
||||
}
|
||||
if (
|
||||
files.length > CONFIRM_ABOVE &&
|
||||
!(await confirm({ title: "Code Cleanup", message: `Clean up ${files.length} files?`, ok: "Clean Up" }))
|
||||
!(await confirm({ title: "Code Cleanup", message: tx`Clean up ${files.length} files?`, ok: "Clean Up" }))
|
||||
)
|
||||
return;
|
||||
const editors = maybeEditorService();
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
} from "@/platform/ipc";
|
||||
import { notifications } from "@/workbench/contributions";
|
||||
import { resolveScope, type ScopeChoice } from "./scope";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
const STATE_KEY = "openidea.analysis.structural.v1";
|
||||
|
||||
@@ -152,7 +153,7 @@ export async function showStructuralResults(
|
||||
group: "analysis",
|
||||
level: "warning",
|
||||
title: "Search Structurally",
|
||||
body: `Stopped after ${summary.matches} matches`,
|
||||
body: tx`Stopped after ${summary.matches} matches`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import { useProject } from "@/platform/project";
|
||||
import { notifications, registerEditorBanner } from "@/workbench/contributions";
|
||||
import { promptInput } from "@/workbench/inputDialogs";
|
||||
import { showNewProject } from "./NewProject";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
/** localStorage prefixes of IDE-level state exported with the settings (templates, macros, layouts). */
|
||||
export const EXPORTED_STORAGE = [
|
||||
@@ -93,7 +94,7 @@ async function renameProject() {
|
||||
initial: project.name,
|
||||
okLabel: "Rename",
|
||||
validate: () => null,
|
||||
hint: `Leave empty to use the folder name (${folder}).`,
|
||||
hint: tx`Leave empty to use the folder name (${folder}).`,
|
||||
});
|
||||
if (name === null) return;
|
||||
try {
|
||||
|
||||
@@ -43,6 +43,7 @@ import {
|
||||
useBuild,
|
||||
} from "./store";
|
||||
import styles from "./BuildTools.module.css";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
export function MavenView() {
|
||||
return <BuildToolView tool="maven" />;
|
||||
@@ -292,8 +293,8 @@ function BuildToolView({ tool }: { tool: BuildTool }) {
|
||||
const config = isRunnable(node) && model ? nodeConfig(nodes.filter(isRunnable), model) : null;
|
||||
if (config) {
|
||||
items.push(
|
||||
{ label: `Run '${config.name}'`, icon: "run", run: () => runConfig(config, "run") },
|
||||
{ label: `Debug '${config.name}'`, icon: "debug", run: () => runConfig(config, "debug") },
|
||||
{ label: tx`Run '${config.name}'`, icon: "run", run: () => runConfig(config, "run") },
|
||||
{ label: tx`Debug '${config.name}'`, icon: "debug", run: () => runConfig(config, "debug") },
|
||||
{ kind: "separator" },
|
||||
);
|
||||
if (node.kind === "runConfig")
|
||||
@@ -318,7 +319,7 @@ function BuildToolView({ tool }: { tool: BuildTool }) {
|
||||
const file = node.project.buildFile;
|
||||
if (file)
|
||||
items.push({
|
||||
label: `Open ${file.split("/").pop()}`,
|
||||
label: tx`Open ${file.split("/").pop()}`,
|
||||
icon: "file-gradle",
|
||||
run: () => void editorService().openFile(`${root}/${file}`),
|
||||
});
|
||||
|
||||
@@ -27,6 +27,7 @@ import {
|
||||
type HierarchyNode,
|
||||
} from "./hierarchy";
|
||||
import styles from "./HierarchyView.module.css";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
type Node = { kind: "root"; id: string } | { kind: "item"; id: string; node: HierarchyNode };
|
||||
|
||||
@@ -78,7 +79,7 @@ function HierarchyToolbar() {
|
||||
icon="arrow-up"
|
||||
size="small"
|
||||
iconSize={16}
|
||||
title={`${directionLabel(mode, "incoming")} Hierarchy`}
|
||||
title={tx`${directionLabel(mode, "incoming")} Hierarchy`}
|
||||
pressed={direction === "incoming"}
|
||||
onClick={() => setDirection("incoming")}
|
||||
/>
|
||||
@@ -86,7 +87,7 @@ function HierarchyToolbar() {
|
||||
icon="arrow-down"
|
||||
size="small"
|
||||
iconSize={16}
|
||||
title={`${directionLabel(mode, "outgoing")} Hierarchy`}
|
||||
title={tx`${directionLabel(mode, "outgoing")} Hierarchy`}
|
||||
pressed={direction === "outgoing"}
|
||||
onClick={() => setDirection("outgoing")}
|
||||
/>
|
||||
|
||||
@@ -7,6 +7,7 @@ import { downloadJdkActions } from "@/platform/jdk";
|
||||
import { relativePath, useProject } from "@/platform/project";
|
||||
import { STATUS_LABEL, restartServer, serversSummary, useServers } from "./servers";
|
||||
import styles from "./ServerStatus.module.css";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
export function ServerStatus() {
|
||||
const map = useServers((s) => s.servers);
|
||||
@@ -23,7 +24,7 @@ export function ServerStatus() {
|
||||
<BarButton
|
||||
ref={ref}
|
||||
aria-expanded={open}
|
||||
aria-label={`Language servers: ${summary.text}`}
|
||||
aria-label={tx`Language servers: ${summary.text}`}
|
||||
tooltip="Language servers"
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
>
|
||||
@@ -65,7 +66,7 @@ export function ServerStatus() {
|
||||
) : s.status === "missing" && canInstall ? (
|
||||
<Button
|
||||
size="small"
|
||||
aria-label={`Install ${s.name}`}
|
||||
aria-label={tx`Install ${s.name}`}
|
||||
onClick={() => {
|
||||
setOpen(false);
|
||||
void executeAction("tools.install", s.name);
|
||||
@@ -77,7 +78,7 @@ export function ServerStatus() {
|
||||
<IconButton
|
||||
icon="refresh"
|
||||
size="small"
|
||||
title={`Restart ${s.name}`}
|
||||
title={tx`Restart ${s.name}`}
|
||||
disabled={s.status === "missing" || s.status === "starting"}
|
||||
onClick={() => void restartServer(s.id)}
|
||||
/>
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
/** "problems" file decorations: files with errors (and their folders) get IDEA's red underline. */
|
||||
import { setFileDecorations, type FileDecoration } from "@/workbench/contributions";
|
||||
import { countSeverities, fileDiagnostics, useProblems, type ProblemsMap } from "./problemsStore";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
export function problemDecorations(map: ProblemsMap): Map<string, FileDecoration> {
|
||||
const out = new Map<string, FileDecoration>();
|
||||
for (const path of map.keys()) {
|
||||
const c = countSeverities(fileDiagnostics(map, path));
|
||||
if (!c.error) continue;
|
||||
out.set(path, {
|
||||
error: true,
|
||||
propagate: true,
|
||||
tooltip: `${c.error} ${c.error === 1 ? "error" : "errors"}${c.warning ? `, ${c.warning} ${c.warning === 1 ? "warning" : "warnings"}` : ""}`,
|
||||
});
|
||||
const errors = c.error === 1 ? tx`${c.error} error` : tx`${c.error} errors`;
|
||||
const warnings = !c.warning ? "" : c.warning === 1 ? tx`${c.warning} warning` : tx`${c.warning} warnings`;
|
||||
out.set(path, { error: true, propagate: true, tooltip: warnings ? `${errors}, ${warnings}` : errors });
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import { call, commands, isTauri, type InstallCommand, type RunConfig } from "@/
|
||||
import { notifications, toolWindowService, type ExecutorLaunch, type RunExecutorContribution } from "@/workbench/contributions";
|
||||
import { coverageSupports, formatPercent } from "./model";
|
||||
import { addSuite } from "./store";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
const errorText = (e: unknown) => (e instanceof Error ? e.message : String(e));
|
||||
|
||||
@@ -47,7 +48,7 @@ export function notifyMissingTool(
|
||||
level: "warning",
|
||||
key: `${group}-missing-${tool}`,
|
||||
title: `${tool} is not installed`,
|
||||
body: line ? `${missing.message} Install it with: ${line}` : missing.homepage ? `${missing.message} ${missing.homepage}` : missing.message,
|
||||
body: line ? tx`${missing.message} Install it with: ${line}` : missing.homepage ? `${missing.message} ${missing.homepage}` : missing.message,
|
||||
sticky: true,
|
||||
actions,
|
||||
});
|
||||
|
||||
@@ -8,6 +8,7 @@ import { CodePreview } from "./CodePreview";
|
||||
import { guessSeparator, importEdits, parseDelimited } from "./model";
|
||||
import { closeDialog, detailsKey, loadDetails, openConsoleWith, targetLabel, useDatabase } from "./store";
|
||||
import styles from "./Database.module.css";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
function when(t: number): string {
|
||||
const d = new Date(t);
|
||||
@@ -60,7 +61,7 @@ export function HistoryDialog({ id, path }: { id: string; path: string | null })
|
||||
<Dialog
|
||||
open
|
||||
onClose={closeDialog}
|
||||
title={`${targetLabel(id)} Query History`}
|
||||
title={tx`${targetLabel(id)} Query History`}
|
||||
width={820}
|
||||
footerStart={
|
||||
<IconButton icon="trash" title="Clear History" disabled={!entries?.length} onClick={() => void remove(null)} />
|
||||
@@ -192,12 +193,12 @@ export function ImportDialog({ id, schema, table }: { id: string; schema: string
|
||||
<Dialog
|
||||
open
|
||||
onClose={closeDialog}
|
||||
title={`Import Data into ${schema}.${table}`}
|
||||
title={tx`Import Data into ${schema}.${table}`}
|
||||
width={720}
|
||||
buttons={[
|
||||
{ label: "Cancel", role: "cancel" },
|
||||
{
|
||||
label: `Import ${edits.length} Rows`,
|
||||
label: tx`Import ${edits.length} Rows`,
|
||||
role: "default",
|
||||
disabled: !edits.length || !mapped.length || busy,
|
||||
onClick: () => void run(),
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
} from "./resultView";
|
||||
import { openDialog } from "./store";
|
||||
import styles from "./Database.module.css";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
export type DataPanel = "record" | "value" | "aggregates";
|
||||
|
||||
@@ -30,7 +31,7 @@ export function exportMenu(data: ExportData, source: string, format?: ExportForm
|
||||
{ label: "Export Data…", icon: "export", run: () => openDialog({ kind: "export", data, source, format }) },
|
||||
{ kind: "separator" },
|
||||
...EXPORT_FORMATS.map((f): MenuItem => ({
|
||||
label: `Copy as ${f.label}`,
|
||||
label: tx`Copy as ${f.label}`,
|
||||
icon: "copy",
|
||||
run: () => void navigator.clipboard?.writeText(exportData(f.id, data)),
|
||||
})),
|
||||
@@ -207,14 +208,14 @@ function FilterPopup(props: {
|
||||
anchor={props.anchor}
|
||||
placement="bottom-start"
|
||||
onClose={props.onClose}
|
||||
aria-label={`Local filter of ${props.column}`}
|
||||
aria-label={tx`Local filter of ${props.column}`}
|
||||
className={styles.filterPopup}
|
||||
trapFocus
|
||||
>
|
||||
<Input
|
||||
autoFocus
|
||||
aria-label="Search values"
|
||||
placeholder={`Values of ${props.column}`}
|
||||
placeholder={tx`Values of ${props.column}`}
|
||||
value={query}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
/>
|
||||
|
||||
@@ -7,6 +7,7 @@ import { SourceDialog } from "./SourceDialog";
|
||||
import { closeDialog, useDatabase } from "./store";
|
||||
import styles from "./Database.module.css";
|
||||
import { isImeKey } from "@/platform/ime";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
const ObjectDialogs = lazyComponent(() => import("./ObjectDialogs").then((m) => m.ObjectDialogs));
|
||||
const ExportDialog = lazyComponent(() => import("./ExportDialog").then((m) => m.ExportDialog));
|
||||
@@ -28,7 +29,7 @@ function PasswordDialog({ source, resolve }: { source: DataSource; resolve: (ok:
|
||||
<Dialog
|
||||
open
|
||||
onClose={() => done(false)}
|
||||
title={`Connect to ${source.name}`}
|
||||
title={tx`Connect to ${source.name}`}
|
||||
width={400}
|
||||
buttons={[
|
||||
{ label: "Cancel", role: "cancel" },
|
||||
@@ -82,7 +83,7 @@ function SshSecretDialog({
|
||||
<Dialog
|
||||
open
|
||||
onClose={() => done(false)}
|
||||
title={`SSH: ${sshLabel(source) || source.name}`}
|
||||
title={tx`SSH: ${sshLabel(source) || source.name}`}
|
||||
width={440}
|
||||
buttons={[
|
||||
{ label: "Cancel", role: "cancel" },
|
||||
|
||||
@@ -38,6 +38,7 @@ import {
|
||||
} from "./store";
|
||||
import { openTableData } from "./treeActions";
|
||||
import styles from "./Database.module.css";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
/** Read-only SQL with the editor's syntax colours (IDEA's dialog Preview pane). */
|
||||
function SqlPreview({ sql, label = "Preview" }: { sql: string; label?: string }) {
|
||||
@@ -287,7 +288,7 @@ function ModifyTableDialog(props: ModifyProps) {
|
||||
<Dialog
|
||||
open
|
||||
onClose={closeDialog}
|
||||
title={`Modify Table ${table}`}
|
||||
title={tx`Modify Table ${table}`}
|
||||
width={440}
|
||||
buttons={[{ label: "Cancel", role: "cancel" }]}
|
||||
>
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
type DbSslMode,
|
||||
type DbTxMode,
|
||||
} from "@/platform/ipc";
|
||||
import { useTx, useTxTemplate } from "@/platform/i18n";
|
||||
import { tx, useTx, useTxTemplate } from "@/platform/i18n";
|
||||
import { Button, Checkbox, Dialog, IconButton, Input, Select, Tabs, T, type SelectOption } from "@/ui";
|
||||
import { colorVar, connectRemedy, fileSourceName, newSourceId, parseSourceUrl, sshLabel } from "./model";
|
||||
import { closeDialog, loadDatabases, loadSchemas, saveSource, useDatabase } from "./store";
|
||||
@@ -224,7 +224,7 @@ function SecondsOption({
|
||||
<Input
|
||||
className={styles.secondsInput}
|
||||
inputMode="numeric"
|
||||
aria-label={`${label} (seconds)`}
|
||||
aria-label={tx`${label} (seconds)`}
|
||||
disabled={!on}
|
||||
value={draft}
|
||||
onChange={(e) => {
|
||||
@@ -243,14 +243,18 @@ function SecondsOption({
|
||||
|
||||
/** Schemas tab: "All …" or a choice of names and `*` / `?` patterns. */
|
||||
function NamePicker({
|
||||
title,
|
||||
allLabel,
|
||||
addLabel,
|
||||
all,
|
||||
chosen,
|
||||
known,
|
||||
onAll,
|
||||
onChosen,
|
||||
}: {
|
||||
title: string;
|
||||
/** "All databases" */
|
||||
allLabel: string;
|
||||
/** Accessible name of the pattern input. */
|
||||
addLabel: string;
|
||||
all: boolean;
|
||||
chosen: string[];
|
||||
known: string[];
|
||||
@@ -266,7 +270,7 @@ function NamePicker({
|
||||
};
|
||||
return (
|
||||
<div className={styles.namePicker}>
|
||||
<Checkbox checked={all} onChange={onAll} label={`All ${title}`} />
|
||||
<Checkbox checked={all} onChange={onAll} label={allLabel} />
|
||||
{!all && (
|
||||
<div className={styles.nameList}>
|
||||
{names.map((n) => (
|
||||
@@ -282,7 +286,7 @@ function NamePicker({
|
||||
className={styles.fill}
|
||||
value={pattern}
|
||||
placeholder="Name or pattern, e.g. app_*"
|
||||
aria-label={`Add ${title} pattern`}
|
||||
aria-label={addLabel}
|
||||
onChange={(e) => setPattern(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter" && !isImeKey(e.nativeEvent)) {
|
||||
@@ -401,7 +405,7 @@ export function SourceDialog({
|
||||
setTest(null);
|
||||
try {
|
||||
const v = await call(commands.dbTest(effective(), password ?? null, sshOn ? (sshSecret ?? null) : null));
|
||||
setTest({ ok: true, text: `Succeeded: ${v}` });
|
||||
setTest({ ok: true, text: tx`Succeeded: ${v}` });
|
||||
} catch (e) {
|
||||
const text = e instanceof Error ? e.message : String(e);
|
||||
const trust = e instanceof IpcError && connectRemedy(e.kind, e.message) === "trustHostKey";
|
||||
@@ -802,7 +806,8 @@ export function SourceDialog({
|
||||
<div className={styles.formWide}>
|
||||
{postgres && (
|
||||
<NamePicker
|
||||
title="databases"
|
||||
allLabel={tx("All databases")}
|
||||
addLabel={tx("Add databases pattern")}
|
||||
all={intro.allDatabases !== false}
|
||||
chosen={intro.databases ?? []}
|
||||
known={knownDbs}
|
||||
@@ -811,7 +816,8 @@ export function SourceDialog({
|
||||
/>
|
||||
)}
|
||||
<NamePicker
|
||||
title={s.driver === "mysql" ? "schemas (databases)" : "schemas"}
|
||||
allLabel={s.driver === "mysql" ? tx("All schemas (databases)") : tx("All schemas")}
|
||||
addLabel={s.driver === "mysql" ? tx("Add schemas (databases) pattern") : tx("Add schemas pattern")}
|
||||
all={intro.allSchemas !== false}
|
||||
chosen={intro.schemas ?? []}
|
||||
known={knownSchemas}
|
||||
@@ -921,7 +927,7 @@ export function SourceDialog({
|
||||
<Dialog
|
||||
open
|
||||
onClose={closeDialog}
|
||||
title={initial ? `Data Source: ${initial.name}` : "New Data Source"}
|
||||
title={initial ? tx`Data Source: ${initial.name}` : "New Data Source"}
|
||||
width={640}
|
||||
footerStart={
|
||||
<Button onClick={() => void runTest()} disabled={busy || !valid}>
|
||||
|
||||
@@ -29,6 +29,7 @@ import {
|
||||
import { openDialog, sourceById, withConnection } from "./store";
|
||||
import type { TableRef } from "./tableInput";
|
||||
import styles from "./Database.module.css";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
const PAGE_SIZES = ["100", "500", "1000", "5000"];
|
||||
|
||||
@@ -306,7 +307,7 @@ export function TableEditor({ input }: { input: EditorInput }) {
|
||||
) : (
|
||||
<div className={styles.fill}>
|
||||
<DataView
|
||||
aria-label={`${ref.table} data`}
|
||||
aria-label={tx`${ref.table} data`}
|
||||
columns={gridColumns}
|
||||
rowCount={rowCount}
|
||||
fixedRows={loaded}
|
||||
|
||||
@@ -58,6 +58,7 @@ import {
|
||||
useDatabase,
|
||||
} from "./store";
|
||||
import styles from "./Database.module.css";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
/** `templates` feature's language-data key for finer template contexts. */
|
||||
const TEMPLATE_CONTEXT_KEY = "openideaTemplateContexts";
|
||||
@@ -287,7 +288,7 @@ function ConsoleBar({ path, view }: { path: string; view: EditorView }) {
|
||||
<Select
|
||||
aria-label="Row limit"
|
||||
value={String(maxRows)}
|
||||
options={ROW_LIMITS.map((v) => ({ value: v, label: `${Number(v).toLocaleString("en")} rows` }))}
|
||||
options={ROW_LIMITS.map((v) => ({ value: v, label: tx`${Number(v).toLocaleString("en")} rows` }))}
|
||||
onChange={(v) => useDatabase.setState({ maxRows: Number(v) })}
|
||||
/>
|
||||
<span className={styles.toolbarSeparator} />
|
||||
|
||||
@@ -38,6 +38,7 @@ import type { ExportData, ExportFormat } from "./export";
|
||||
import type { DbObjectRef } from "./objects";
|
||||
import { formatted } from "./sql/format";
|
||||
import { bindParams, findParams } from "./sql/params";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
export const DB_TOOL_WINDOW = "database";
|
||||
export const RESULTS_VIEW = "dbResults";
|
||||
@@ -281,7 +282,7 @@ export async function renameSource(id: string, name: string): Promise<void> {
|
||||
export async function removeSource(source: DataSource): Promise<void> {
|
||||
const ok = await confirm({
|
||||
title: "Remove Data Source",
|
||||
message: `Remove data source '${source.name}'? Its query console file stays on disk.`,
|
||||
message: tx`Remove data source '${source.name}'? Its query console file stays on disk.`,
|
||||
ok: "Remove",
|
||||
});
|
||||
if (!ok) return;
|
||||
@@ -788,7 +789,7 @@ export async function executeConsole(
|
||||
.filter((o) => o.result?.columns.length)
|
||||
.map((outcome) => {
|
||||
const n = nextTab++;
|
||||
return { id: n, title: `Result ${n}`, path, sourceId: id, outcome };
|
||||
return { id: n, title: tx`Result ${n}`, path, sourceId: id, outcome };
|
||||
});
|
||||
const failed = outcomes.some((o) => o.error);
|
||||
useDatabase.setState((s) => ({
|
||||
@@ -957,7 +958,7 @@ export async function finishTransaction(id: string, commit: boolean): Promise<bo
|
||||
async function askEndTransaction(source: DataSource): Promise<boolean | null> {
|
||||
const { button } = await ask({
|
||||
title: "Switch to Auto-Commit",
|
||||
body: `${source.name} has uncommitted changes. Commit or roll them back before switching to auto-commit?`,
|
||||
body: tx`${source.name} has uncommitted changes. Commit or roll them back before switching to auto-commit?`,
|
||||
buttons: [
|
||||
{ id: "rollback", label: "Roll Back" },
|
||||
{ id: "commit", label: "Commit", primary: true },
|
||||
|
||||
@@ -37,6 +37,7 @@ import {
|
||||
removeSource,
|
||||
} from "./store";
|
||||
import { tableInput } from "./tableInput";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
/** Context key: the Database tree has focus. */
|
||||
export const DB_VIEW_FOCUS = "databaseViewFocus";
|
||||
@@ -57,11 +58,12 @@ function sourceOf(n: DbNode | null): DataSource | undefined {
|
||||
return n ? sourceById(nodeTarget(n)) : undefined;
|
||||
}
|
||||
|
||||
async function copy(text: string, what: string) {
|
||||
/** Copies `text`; `failure` is the notification title when the clipboard refuses it. */
|
||||
async function copy(text: string, failure: string) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
} catch {
|
||||
notifications().notify({ level: "error", title: `Cannot copy the ${what}` });
|
||||
notifications().notify({ level: "error", title: failure });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -373,10 +375,10 @@ export function registerDatabaseTreeActions(): () => void {
|
||||
const n = nodeFrom(arg);
|
||||
if (!n) return;
|
||||
const id = nodeTarget(n);
|
||||
if (n.kind === "source") return void copy(n.source.name ?? "", "name");
|
||||
if (n.kind === "database") return void copy(n.name, "name");
|
||||
if (n.kind === "source") return void copy(n.source.name ?? "", tx("Cannot copy the name"));
|
||||
if (n.kind === "database") return void copy(n.name, tx("Cannot copy the name"));
|
||||
const o = objectOf(n);
|
||||
if (id && o) void copy(reference(driverOf(id), o), "reference");
|
||||
if (id && o) void copy(reference(driverOf(id), o), tx("Cannot copy the reference"));
|
||||
},
|
||||
}),
|
||||
tree({
|
||||
@@ -397,7 +399,7 @@ export function registerDatabaseTreeActions(): () => void {
|
||||
run: async ({ arg }) => {
|
||||
const n = nodeFrom(arg);
|
||||
const ddl = n && (await ddlOf(n));
|
||||
if (ddl) await copy(ddl.text, "DDL");
|
||||
if (ddl) await copy(ddl.text, tx("Cannot copy the DDL"));
|
||||
},
|
||||
}),
|
||||
tree({
|
||||
|
||||
@@ -43,6 +43,7 @@ import {
|
||||
openSmartStepChooser,
|
||||
useOverlays,
|
||||
} from "./ui/popoverStore";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
function isRunConfig(arg: unknown): arg is RunConfig {
|
||||
return !!arg && typeof arg === "object" && "command" in arg && "args" in arg && "debugAdapter" in arg;
|
||||
@@ -159,7 +160,7 @@ async function listenForJvm(name: string, host: string, port: number): Promise<n
|
||||
key,
|
||||
sticky: true,
|
||||
title: `'${name}': listening for the remote JVM on port ${port}`,
|
||||
body: `Start the remote JVM with -agentlib:jdwp=transport=dt_socket,server=n,address=${host}:${port},suspend=y`,
|
||||
body: tx`Start the remote JVM with -agentlib:jdwp=transport=dt_socket,server=n,address=${host}:${port},suspend=y`,
|
||||
actions: [{ label: "Cancel", run: () => void commands.cancelRequest(request) }],
|
||||
});
|
||||
try {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
import { call, commands, isTauri, type DebugEvent, type DebugSessionId } from "@/platform/ipc";
|
||||
import { maybeEditorService, notifications } from "@/workbench/contributions";
|
||||
import { isLive, useDebug, type DebugSession } from "./state";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
const KEY = "debug.hotswap";
|
||||
/** `BUILD_COMPLETE` events of our own build are not worth a prompt. */
|
||||
@@ -25,7 +26,7 @@ function plural(n: number, word: string) {
|
||||
export function hotSwapMessage(changed: number, errors: string[]): { level: "info" | "error"; title: string; body?: string } {
|
||||
if (errors.length) return { level: "error", title: "Hot Swap failed", body: errors.join("\n") };
|
||||
if (changed === 0) return { level: "info", title: "Loaded classes are up to date. Nothing to reload." };
|
||||
return { level: "info", title: `${plural(changed, "class")} reloaded` };
|
||||
return { level: "info", title: tx`${plural(changed, "class")} reloaded` };
|
||||
}
|
||||
|
||||
/** Compiles (unless `build` is false) and reloads changed classes into every Java debug session. */
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
import { IpcError } from "@/platform/ipc";
|
||||
|
||||
/** Adapters the tools installer can provide (adapter id → tool name). */
|
||||
const INSTALLABLE: Record<string, { tool: string; label: string }> = {
|
||||
debugpy: { tool: "debugpy", label: "debugpy" },
|
||||
"js-debug": { tool: "js-debug", label: "the JavaScript debugger (vscode-js-debug)" },
|
||||
delve: { tool: "delve", label: "Delve" },
|
||||
codelldb: { tool: "codelldb", label: "CodeLLDB" },
|
||||
const INSTALLABLE: Record<string, { tool: string; title: string }> = {
|
||||
debugpy: { tool: "debugpy", title: "debugpy is not installed" },
|
||||
"js-debug": { tool: "js-debug", title: "The JavaScript debugger (vscode-js-debug) is not installed" },
|
||||
delve: { tool: "delve", title: "Delve is not installed" },
|
||||
codelldb: { tool: "codelldb", title: "CodeLLDB is not installed" },
|
||||
};
|
||||
|
||||
export interface MissingAdapter {
|
||||
@@ -25,14 +25,14 @@ export function missingAdapter(adapter: string, e: unknown): MissingAdapter | nu
|
||||
if (adapter === "debugpy" && e.message.startsWith("debugpy is not installed")) {
|
||||
return {
|
||||
tool: entry.tool,
|
||||
title: "debugpy is not installed",
|
||||
title: entry.title,
|
||||
body: `${e.message}. OpenIDEA can install a private copy that every Python interpreter uses for debugging.`,
|
||||
};
|
||||
}
|
||||
if (!e.message.startsWith(`debug adapter \`${adapter}\` not found`)) return null;
|
||||
return {
|
||||
tool: entry.tool,
|
||||
title: `${entry.label[0]!.toUpperCase()}${entry.label.slice(1)} is not installed`,
|
||||
title: entry.title,
|
||||
body: e.message,
|
||||
};
|
||||
}
|
||||
@@ -40,6 +40,7 @@ import {
|
||||
} from "../state";
|
||||
import { VariablesView, type VarRoot } from "./VariablesView";
|
||||
import styles from "./DebugToolWindow.module.css";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
function useActionEnabled(id: string): boolean {
|
||||
const ctx = useContextKeys();
|
||||
@@ -114,7 +115,7 @@ export function DebugTabs() {
|
||||
if (!list.length) return null;
|
||||
const items: TabItem[] = list.map((s) => ({
|
||||
id: String(s.id),
|
||||
label: s.parent != null ? `${s.name} (child)` : s.name,
|
||||
label: s.parent != null ? tx`${s.name} (child)` : s.name,
|
||||
text: s.name,
|
||||
icon: "debug",
|
||||
italic: s.status === "terminated",
|
||||
|
||||
@@ -34,6 +34,7 @@ import { VariablesView, type VarRoot } from "./VariablesView";
|
||||
import { pushHistory, readHistory } from "./expressionHistory";
|
||||
import styles from "./Overlays.module.css";
|
||||
import { isImeKey } from "@/platform/ime";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
export function DebuggerOverlays() {
|
||||
return (
|
||||
@@ -447,7 +448,7 @@ function BreakpointsDialog() {
|
||||
<Checkbox
|
||||
checked={r.bp.enabled}
|
||||
onChange={(enabled) => updateSpecial(r.bp.id, { enabled })}
|
||||
aria-label={`Enable ${specialTitle(r.bp)}`}
|
||||
aria-label={tx`Enable ${specialTitle(r.bp)}`}
|
||||
/>
|
||||
<Icon name={r.bp.kind === "method" ? "breakpoint-method" : "breakpoint-field"} size={14} />
|
||||
<span className={styles.bpName}>{specialTitle(r.bp)}</span>
|
||||
@@ -467,7 +468,7 @@ function BreakpointsDialog() {
|
||||
<Checkbox
|
||||
checked={r.bp.enabled}
|
||||
onChange={(enabled) => updateBreakpoint(r.path, r.bp.id, { enabled })}
|
||||
aria-label={`Enable breakpoint at ${basename(r.path)}:${r.bp.line + 1}`}
|
||||
aria-label={tx`Enable breakpoint at ${basename(r.path)}:${r.bp.line + 1}`}
|
||||
/>
|
||||
<span
|
||||
className={styles.bpDot}
|
||||
|
||||
@@ -35,6 +35,7 @@ import {
|
||||
import { addComment, checkoutPullRequest, openCommentLocation, openFileDiff, openUrl, submitReview } from "./ops";
|
||||
import { cancelBusy, loadDetails, refreshAll, select, setQuery, useGithub, type DetailTab } from "./store";
|
||||
import styles from "./Github.module.css";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
const STATES: Array<{ value: PrStateFilter; label: string }> = [
|
||||
{ value: "open", label: "Open" },
|
||||
@@ -515,9 +516,9 @@ function Details() {
|
||||
aria-label="Pull request"
|
||||
items={[
|
||||
{ id: "overview", label: "Overview" },
|
||||
{ id: "files", label: `Files ${pr.files.length}` },
|
||||
{ id: "commits", label: `Commits ${pr.commits.length}` },
|
||||
{ id: "conversation", label: `Conversation ${pr.timeline.length + comments.length}` },
|
||||
{ id: "files", label: tx`Files ${pr.files.length}` },
|
||||
{ id: "commits", label: tx`Commits ${pr.commits.length}` },
|
||||
{ id: "conversation", label: tx`Conversation ${pr.timeline.length + comments.length}` },
|
||||
]}
|
||||
/>
|
||||
{tab === "overview" && <Overview pr={pr} />}
|
||||
|
||||
@@ -5,6 +5,7 @@ import type { ReviewEvent } from "@/platform/ipc";
|
||||
import { call, commands } from "@/platform/ipc";
|
||||
import { Checkbox, Dialog, Input, Select, T } from "@/ui";
|
||||
import styles from "./Github.module.css";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
interface Entry {
|
||||
id: number;
|
||||
@@ -134,7 +135,7 @@ function CreateDialog(props: {
|
||||
/>
|
||||
<div className={styles.formRow}>
|
||||
<Checkbox checked={draft} onChange={setDraft} label="Draft" />
|
||||
<Checkbox checked={push} onChange={setPush} label={`Push '${props.head}' first`} />
|
||||
<Checkbox checked={push} onChange={setPush} label={tx`Push '${props.head}' first`} />
|
||||
</div>
|
||||
</div>
|
||||
</Dialog>
|
||||
@@ -165,7 +166,7 @@ function ReviewDialog(props: {
|
||||
return (
|
||||
<Dialog
|
||||
open
|
||||
title={`Review #${props.number}`}
|
||||
title={tx`Review #${props.number}`}
|
||||
onClose={() => props.onDone(null)}
|
||||
width={520}
|
||||
buttons={[
|
||||
|
||||
@@ -10,6 +10,7 @@ import { EmptyState, IconButton, SplitGroup, SplitHandle, SplitPanel, Spinner, T
|
||||
import { bodyKind, formatMs, formatSize, prettyBody } from "./format";
|
||||
import { cancelRunning, clearHistory, refreshHistory, selectEntry, useHttpClient } from "./store";
|
||||
import styles from "./HttpClient.module.css";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
function statusTone(status: number | null | undefined): string {
|
||||
if (status == null) return styles.statusError ?? "";
|
||||
@@ -73,7 +74,7 @@ function ExchangeView({ ex }: { ex: HttpExchange }) {
|
||||
onSelect={(id) => setTab(id as Tab)}
|
||||
items={[
|
||||
{ id: "body", label: "Response" },
|
||||
{ id: "headers", label: `Headers${r ? ` (${r.headers.length})` : ""}` },
|
||||
{ id: "headers", label: r ? tx`Headers (${r.headers.length})` : "Headers" },
|
||||
{ id: "request", label: "Request" },
|
||||
]}
|
||||
trailing={
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { useState } from "react";
|
||||
import { create } from "zustand";
|
||||
import { executeAction, getAction } from "@/platform/actions";
|
||||
import { t } from "@/platform/i18n";
|
||||
import { t, tx } from "@/platform/i18n";
|
||||
import { BarButton, Button, Dialog, Icon, List, T } from "@/ui";
|
||||
import { confirm } from "@/workbench/messages";
|
||||
import { promptInput } from "@/workbench/inputDialogs";
|
||||
@@ -60,7 +60,7 @@ function EditMacrosDialog({ onClose }: { onClose: () => void }) {
|
||||
};
|
||||
const remove = async () => {
|
||||
if (!macro) return;
|
||||
if (await confirm({ title: "Delete Macro", message: `Delete the macro '${macro.name}'?`, ok: "Delete", icon: "warning" }))
|
||||
if (await confirm({ title: "Delete Macro", message: tx`Delete the macro '${macro.name}'?`, ok: "Delete", icon: "warning" }))
|
||||
deleteMacro(macro.name);
|
||||
};
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import { indicatorLabel, indicatorTooltip, memorySections, summarizeMemory } fro
|
||||
import { startPolling } from "./poll";
|
||||
import { METRICS_INTERVAL_MS, refreshMetrics, usePerf } from "./store";
|
||||
import styles from "./perf.module.css";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
/** Status bar widget id (hidden by default, toggled from the status bar context menu). */
|
||||
export const MEMORY_WIDGET = { id: "perf.memory", title: "Memory Indicator", defaultVisible: false } as const;
|
||||
@@ -41,7 +42,7 @@ export function MemoryStatus() {
|
||||
ref={ref}
|
||||
className={styles.indicator}
|
||||
aria-expanded={open}
|
||||
aria-label={`Memory: ${tooltip}`}
|
||||
aria-label={tx`Memory: ${tooltip}`}
|
||||
tooltip={tooltip}
|
||||
onClick={() => usePerf.setState({ popupOpen: !open })}
|
||||
>
|
||||
@@ -101,7 +102,7 @@ export function MemoryDetails({ metrics: m }: { metrics: AppMetrics }) {
|
||||
label={r.label}
|
||||
detail={r.detail}
|
||||
value={r.value}
|
||||
title={r.processes > 1 ? `${r.processes} processes` : undefined}
|
||||
title={r.processes > 1 ? tx`${r.processes} processes` : undefined}
|
||||
indented
|
||||
/>
|
||||
))}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { useProject } from "@/platform/project";
|
||||
import { formatSize } from "./format";
|
||||
import { MEMORY_WIDGET } from "./MemoryStatus";
|
||||
import { clearCaches, refreshMetrics, usePerf } from "./store";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
function memoryIndicatorShown(): boolean {
|
||||
const overrides = useProject.getState().settings?.appearance?.statusBarWidgets;
|
||||
@@ -30,12 +31,15 @@ export function perfActions(): Action[] {
|
||||
}
|
||||
const memory =
|
||||
r.rssBeforeBytes != null && r.rssAfterBytes != null
|
||||
? ` Memory ${formatSize(r.rssBeforeBytes)} → ${formatSize(r.rssAfterBytes)}.`
|
||||
? tx` Memory ${formatSize(r.rssBeforeBytes)} → ${formatSize(r.rssAfterBytes)}.`
|
||||
: "";
|
||||
notifications().notify({
|
||||
level: "info",
|
||||
title: "Caches cleared",
|
||||
body: `${r.syntaxTrees} syntax tree${r.syntaxTrees === 1 ? "" : "s"} dropped, index compacted.${memory}`,
|
||||
body:
|
||||
r.syntaxTrees === 1
|
||||
? tx`${r.syntaxTrees} syntax tree dropped, index compacted.${memory}`
|
||||
: tx`${r.syntaxTrees} syntax trees dropped, index compacted.${memory}`,
|
||||
key: "perf.clearCaches",
|
||||
});
|
||||
} catch (e) {
|
||||
|
||||