mirror of
https://github.com/ilyakooo0/helix.git
synced 2024-11-24 08:25:17 +03:00
bump MSRV to 1.70.0 (#8877)
* rust-toolchain.toml: bump MSRV to 1.70.0 With Firefox 120 released on 21 November 2023, the MSRV is now 1.70.0. * Fix cargo fmt with Rust 1.70.0 * Fix cargo clippy with Rust 1.70.0 * Fix cargo doc with Rust 1.70.0 * rust-toolchain.toml: add clippy component * .github: bump dtolnay/rust-toolchain to 1.70 * helix-term: bump rust-version to 1.70 * helix-view/gutter: use checked_ilog10 to count digits * helix-core/syntax: use MAIN_SEPARATOR_STR constant * helix-view/handlers/dap: use Display impl for displaying process spawn error * WIP: helix-term/commands: use checked math to assert ranges cannot overlap
This commit is contained in:
parent
090ed97e00
commit
8b0ae3d279
6
.github/workflows/build.yml
vendored
6
.github/workflows/build.yml
vendored
@ -39,7 +39,7 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install stable toolchain
|
- name: Install stable toolchain
|
||||||
uses: dtolnay/rust-toolchain@1.65
|
uses: dtolnay/rust-toolchain@1.70
|
||||||
|
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
with:
|
with:
|
||||||
@ -70,7 +70,7 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install stable toolchain
|
- name: Install stable toolchain
|
||||||
uses: dtolnay/rust-toolchain@1.65
|
uses: dtolnay/rust-toolchain@1.70
|
||||||
with:
|
with:
|
||||||
components: rustfmt, clippy
|
components: rustfmt, clippy
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install stable toolchain
|
- name: Install stable toolchain
|
||||||
uses: dtolnay/rust-toolchain@1.65
|
uses: dtolnay/rust-toolchain@1.70
|
||||||
|
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
with:
|
with:
|
||||||
|
@ -212,10 +212,7 @@ impl<'de> Deserialize<'de> for FileType {
|
|||||||
{
|
{
|
||||||
match map.next_entry::<String, String>()? {
|
match map.next_entry::<String, String>()? {
|
||||||
Some((key, suffix)) if key == "suffix" => Ok(FileType::Suffix({
|
Some((key, suffix)) if key == "suffix" => Ok(FileType::Suffix({
|
||||||
// FIXME: use `suffix.replace('/', std::path::MAIN_SEPARATOR_STR)`
|
suffix.replace('/', std::path::MAIN_SEPARATOR_STR)
|
||||||
// if MSRV is updated to 1.68
|
|
||||||
let mut separator = [0; 1];
|
|
||||||
suffix.replace('/', std::path::MAIN_SEPARATOR.encode_utf8(&mut separator))
|
|
||||||
})),
|
})),
|
||||||
Some((key, _value)) => Err(serde::de::Error::custom(format!(
|
Some((key, _value)) => Err(serde::de::Error::custom(format!(
|
||||||
"unknown key in `file-types` list: {}",
|
"unknown key in `file-types` list: {}",
|
||||||
|
@ -10,7 +10,7 @@ repository = "https://github.com/helix-editor/helix"
|
|||||||
homepage = "https://helix-editor.com"
|
homepage = "https://helix-editor.com"
|
||||||
include = ["src/**/*", "README.md"]
|
include = ["src/**/*", "README.md"]
|
||||||
default-run = "hx"
|
default-run = "hx"
|
||||||
rust-version = "1.65"
|
rust-version = "1.70"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["git"]
|
default = ["git"]
|
||||||
|
@ -1318,7 +1318,7 @@ fn extend_next_long_word_end(cx: &mut Context) {
|
|||||||
extend_word_impl(cx, movement::move_next_long_word_end)
|
extend_word_impl(cx, movement::move_next_long_word_end)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Separate branch to find_char designed only for <ret> char.
|
/// Separate branch to find_char designed only for `<ret>` char.
|
||||||
//
|
//
|
||||||
// This is necessary because the one document can have different line endings inside. And we
|
// This is necessary because the one document can have different line endings inside. And we
|
||||||
// cannot predict what character to find when <ret> is pressed. On the current line it can be `lf`
|
// cannot predict what character to find when <ret> is pressed. On the current line it can be `lf`
|
||||||
@ -5606,12 +5606,18 @@ fn shell(cx: &mut compositor::Context, cmd: &str, behavior: &ShellBehavior) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// These `usize`s cannot underflow because selection ranges cannot overlap.
|
// These `usize`s cannot underflow because selection ranges cannot overlap.
|
||||||
// Once the MSRV is 1.66.0 (mixed_integer_ops is stabilized), we can use checked
|
let anchor = to
|
||||||
// arithmetic to assert this.
|
.checked_add_signed(offset)
|
||||||
let anchor = (to as isize + offset - deleted_len as isize) as usize;
|
.expect("Selection ranges cannot overlap")
|
||||||
|
.checked_sub(deleted_len)
|
||||||
|
.expect("Selection ranges cannot overlap");
|
||||||
let new_range = Range::new(anchor, anchor + output_len).with_direction(range.direction());
|
let new_range = Range::new(anchor, anchor + output_len).with_direction(range.direction());
|
||||||
ranges.push(new_range);
|
ranges.push(new_range);
|
||||||
offset = offset + output_len as isize - deleted_len as isize;
|
offset = offset
|
||||||
|
.checked_add_unsigned(output_len)
|
||||||
|
.expect("Selection ranges cannot overlap")
|
||||||
|
.checked_sub_unsigned(deleted_len)
|
||||||
|
.expect("Selection ranges cannot overlap");
|
||||||
|
|
||||||
changes.push((from, to, Some(output)));
|
changes.push((from, to, Some(output)));
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ use std::{
|
|||||||
/// If there is no configured language server that supports the feature, this displays a status message.
|
/// If there is no configured language server that supports the feature, this displays a status message.
|
||||||
/// Using this macro in a context where the editor automatically queries the LSP
|
/// Using this macro in a context where the editor automatically queries the LSP
|
||||||
/// (instead of when the user explicitly does so via a keybind like `gd`)
|
/// (instead of when the user explicitly does so via a keybind like `gd`)
|
||||||
/// will spam the "No configured language server supports <feature>" status message confusingly.
|
/// will spam the "No configured language server supports \<feature>" status message confusingly.
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! language_server_with_feature {
|
macro_rules! language_server_with_feature {
|
||||||
($editor:expr, $doc:expr, $feature:expr) => {{
|
($editor:expr, $doc:expr, $feature:expr) => {{
|
||||||
|
@ -213,7 +213,7 @@ impl Buffer {
|
|||||||
&& y < self.area.bottom()
|
&& y < self.area.bottom()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the index in the Vec<Cell> for the given global (x, y) coordinates.
|
/// Returns the index in the `Vec<Cell>` for the given global (x, y) coordinates.
|
||||||
///
|
///
|
||||||
/// Global coordinates are offset by the Buffer's area offset (`x`/`y`).
|
/// Global coordinates are offset by the Buffer's area offset (`x`/`y`).
|
||||||
///
|
///
|
||||||
@ -242,7 +242,7 @@ impl Buffer {
|
|||||||
((y - self.area.y) as usize) * (self.area.width as usize) + ((x - self.area.x) as usize)
|
((y - self.area.y) as usize) * (self.area.width as usize) + ((x - self.area.x) as usize)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the index in the Vec<Cell> for the given global (x, y) coordinates,
|
/// Returns the index in the `Vec<Cell>` for the given global (x, y) coordinates,
|
||||||
/// or `None` if the coordinates are outside the buffer's area.
|
/// or `None` if the coordinates are outside the buffer's area.
|
||||||
fn index_of_opt(&self, x: u16, y: u16) -> Option<usize> {
|
fn index_of_opt(&self, x: u16, y: u16) -> Option<usize> {
|
||||||
if self.in_bounds(x, y) {
|
if self.in_bounds(x, y) {
|
||||||
|
@ -727,7 +727,7 @@ pub struct WhitespaceCharacters {
|
|||||||
impl Default for WhitespaceCharacters {
|
impl Default for WhitespaceCharacters {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
space: '·', // U+00B7
|
space: '·', // U+00B7
|
||||||
nbsp: '⍽', // U+237D
|
nbsp: '⍽', // U+237D
|
||||||
tab: '→', // U+2192
|
tab: '→', // U+2192
|
||||||
newline: '⏎', // U+23CE
|
newline: '⏎', // U+23CE
|
||||||
@ -755,12 +755,13 @@ impl Default for IndentGuidesConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Line ending configuration.
|
/// Line ending configuration.
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "lowercase")]
|
#[serde(rename_all = "lowercase")]
|
||||||
pub enum LineEndingConfig {
|
pub enum LineEndingConfig {
|
||||||
/// The platform's native line ending.
|
/// The platform's native line ending.
|
||||||
///
|
///
|
||||||
/// `crlf` on Windows, otherwise `lf`.
|
/// `crlf` on Windows, otherwise `lf`.
|
||||||
|
#[default]
|
||||||
Native,
|
Native,
|
||||||
/// Line feed.
|
/// Line feed.
|
||||||
LF,
|
LF,
|
||||||
@ -777,12 +778,6 @@ pub enum LineEndingConfig {
|
|||||||
Nel,
|
Nel,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for LineEndingConfig {
|
|
||||||
fn default() -> Self {
|
|
||||||
LineEndingConfig::Native
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<LineEndingConfig> for LineEnding {
|
impl From<LineEndingConfig> for LineEnding {
|
||||||
fn from(line_ending: LineEndingConfig) -> Self {
|
fn from(line_ending: LineEndingConfig) -> Self {
|
||||||
match line_ending {
|
match line_ending {
|
||||||
|
@ -9,8 +9,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
fn count_digits(n: usize) -> usize {
|
fn count_digits(n: usize) -> usize {
|
||||||
// TODO: use checked_log10 when MSRV reaches 1.67
|
(usize::checked_ilog10(n).unwrap_or(0) + 1) as usize
|
||||||
std::iter::successors(Some(n), |&n| (n >= 10).then_some(n / 10)).count()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type GutterFn<'doc> = Box<dyn FnMut(usize, bool, bool, &mut String) -> Option<Style> + 'doc>;
|
pub type GutterFn<'doc> = Box<dyn FnMut(usize, bool, bool, &mut String) -> Option<Style> + 'doc>;
|
||||||
|
@ -369,9 +369,7 @@ impl Editor {
|
|||||||
{
|
{
|
||||||
Ok(process) => process,
|
Ok(process) => process,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
// TODO replace the pretty print {:?} with a regular format {}
|
self.set_error(format!("Error starting external terminal: {}", err));
|
||||||
// when the MSRV is raised to 1.60.0
|
|
||||||
self.set_error(format!("Error starting external terminal: {:?}", err));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "1.65.0"
|
channel = "1.70.0"
|
||||||
components = ["rustfmt", "rust-src"]
|
components = ["rustfmt", "rust-src", "clippy"]
|
||||||
|
Loading…
Reference in New Issue
Block a user