mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:38:25 +00:00

## Summary A few smaller editor improvements that felt worth pulling out of my other feature PRs: * Load the `Editor` lazily: This allows splitting the entire monaco javascript into a separate async bundle, drastically reducing the size of the `index.js` * Fix the name of `to_range` and `text_range` to the more idiomatic js names `toRange` and `textRange` * Use one indexed values for `Position::line` and `Position::column`, which is the same as monaco (reduces the need for `+1` and `-1` operations spread all over the place) * Preserve the editor state when navigating between tabs. This ensures that selections are preserved even when switching between tabs. * Stop the default handling of the `Enter` key press event when renaming a file because it resulted in adding a newline in the editor
27 lines
766 B
Rust
27 lines
766 B
Rust
#![cfg(target_arch = "wasm32")]
|
|
|
|
use red_knot_wasm::{Position, Workspace};
|
|
use wasm_bindgen_test::wasm_bindgen_test;
|
|
|
|
#[wasm_bindgen_test]
|
|
fn check() {
|
|
let mut workspace =
|
|
Workspace::new("/", js_sys::JSON::parse("{}").unwrap()).expect("Workspace to be created");
|
|
|
|
workspace
|
|
.open_file("test.py", "import random22\n")
|
|
.expect("File to be opened");
|
|
|
|
let result = workspace.check().expect("Check to succeed");
|
|
|
|
assert_eq!(result.len(), 1);
|
|
|
|
let diagnostic = &result[0];
|
|
|
|
assert_eq!(diagnostic.id(), "lint:unresolved-import");
|
|
assert_eq!(
|
|
diagnostic.to_range(&workspace).unwrap().start,
|
|
Position { line: 1, column: 8 }
|
|
);
|
|
assert_eq!(diagnostic.message(), "Cannot resolve import `random22`");
|
|
}
|