on master help sign in
bump msrv to 1.63 (#5570)
e474779Pascal Kuthe
.github/workflows/build.yml+4−12
@@ -10,19 +10,11 @@ on:
10
10
11jobs:
11jobs:
12 check:
12 check:
13− name: Check
13+ name: Check (msrv)
14 runs-on: ubuntu-latest
14 runs-on: ubuntu-latest
15− strategy:
16− matrix:
17− rust: [stable, msrv]
18 steps:
15 steps:
19 - name: Checkout sources
16 - name: Checkout sources
20 uses: actions/checkout@v3
17 uses: actions/checkout@v3
21−
22− - name: Use MSRV rust toolchain
23− if: matrix.rust == 'msrv'
24− run: cp .github/workflows/msrv-rust-toolchain.toml rust-toolchain.toml
25−
26 - name: Install stable toolchain
18 - name: Install stable toolchain
27 uses: helix-editor/rust-toolchain@v1
19 uses: helix-editor/rust-toolchain@v1
28 with:
20 with:
@@ -45,7 +37,7 @@ jobs:
45 uses: actions/checkout@v3
37 uses: actions/checkout@v3
46
38
47 - name: Install stable toolchain
39 - name: Install stable toolchain
48− uses: dtolnay/rust-toolchain@1.61
40+ uses: dtolnay/rust-toolchain@1.63
49
41
50 - uses: Swatinem/rust-cache@v2
42 - uses: Swatinem/rust-cache@v2
51
43
@@ -74,7 +66,7 @@ jobs:
74 uses: actions/checkout@v3
66 uses: actions/checkout@v3
75
67
76 - name: Install stable toolchain
68 - name: Install stable toolchain
77− uses: dtolnay/rust-toolchain@1.61
69+ uses: dtolnay/rust-toolchain@1.63
78 with:
70 with:
79 components: rustfmt, clippy
71 components: rustfmt, clippy
80
72
@@ -99,7 +91,7 @@ jobs:
99 uses: actions/checkout@v3
91 uses: actions/checkout@v3
100
92
101 - name: Install stable toolchain
93 - name: Install stable toolchain
102− uses: dtolnay/rust-toolchain@1.61
94+ uses: dtolnay/rust-toolchain@1.63
103
95
104 - uses: Swatinem/rust-cache@v2
96 - uses: Swatinem/rust-cache@v2
105
97
.github/workflows/msrv-rust-toolchain.tomldeleted−3
@@ -1,3 +0,0 @@
1−[toolchain]
2−channel = "1.61.0"
3−components = ["rustfmt", "rust-src"]
helix-term/src/commands.rs+3−1
@@ -73,13 +73,15 @@ use grep_searcher::{sinks, BinaryDetection, SearcherBuilder};
73use ignore::{DirEntry, WalkBuilder, WalkState};
73use ignore::{DirEntry, WalkBuilder, WalkState};
74use tokio_stream::wrappers::UnboundedReceiverStream;
74use tokio_stream::wrappers::UnboundedReceiverStream;
75
75
76+pub type OnKeyCallback = Box<dyn FnOnce(&mut Context, KeyEvent)>;
77+
76pub struct Context<'a> {
78pub struct Context<'a> {
77 pub register: Option<char>,
79 pub register: Option<char>,
78 pub count: Option<NonZeroUsize>,
80 pub count: Option<NonZeroUsize>,
79 pub editor: &'a mut Editor,
81 pub editor: &'a mut Editor,
80
82
81 pub callback: Option<crate::compositor::Callback>,
83 pub callback: Option<crate::compositor::Callback>,
82− pub on_next_key_callback: Option<Box<dyn FnOnce(&mut Context, KeyEvent)>>,
84+ pub on_next_key_callback: Option<OnKeyCallback>,
83 pub jobs: &'a mut Jobs,
85 pub jobs: &'a mut Jobs,
84}
86}
85
87
helix-term/src/compositor.rs+1
@@ -7,6 +7,7 @@ use helix_view::graphics::{CursorKind, Rect};
7use tui::buffer::Buffer as Surface;
7use tui::buffer::Buffer as Surface;
8
8
9pub type Callback = Box<dyn FnOnce(&mut Compositor, &mut Context)>;
9pub type Callback = Box<dyn FnOnce(&mut Compositor, &mut Context)>;
10+pub type SyncCallback = Box<dyn FnOnce(&mut Compositor, &mut Context) + Sync>;
10
11
11// Cursive-inspired
12// Cursive-inspired
12pub enum EventResult {
13pub enum EventResult {
helix-term/src/job.rs+5−2
@@ -5,9 +5,12 @@ use crate::compositor::Compositor;
5use futures_util::future::{BoxFuture, Future, FutureExt};
5use futures_util::future::{BoxFuture, Future, FutureExt};
6use futures_util::stream::{FuturesUnordered, StreamExt};
6use futures_util::stream::{FuturesUnordered, StreamExt};
7
7
8+pub type EditorCompositorCallback = Box<dyn FnOnce(&mut Editor, &mut Compositor) + Send>;
9+pub type EditorCallback = Box<dyn FnOnce(&mut Editor) + Send>;
10+
8pub enum Callback {
11pub enum Callback {
9− EditorCompositor(Box<dyn FnOnce(&mut Editor, &mut Compositor) + Send>),
12+ EditorCompositor(EditorCompositorCallback),
10− Editor(Box<dyn FnOnce(&mut Editor) + Send>),
13+ Editor(EditorCallback),
11}
14}
12
15
13pub type JobFuture = BoxFuture<'static, anyhow::Result<Option<Callback>>>;
16pub type JobFuture = BoxFuture<'static, anyhow::Result<Option<Callback>>>;
helix-term/src/ui/editor.rs+2−2
@@ -1,5 +1,5 @@
1use crate::{
1use crate::{
2− commands,
2+ commands::{self, OnKeyCallback},
3 compositor::{Component, Context, Event, EventResult},
3 compositor::{Component, Context, Event, EventResult},
4 job::{self, Callback},
4 job::{self, Callback},
5 key,
5 key,
@@ -37,7 +37,7 @@ use super::{document::LineDecoration, lsp::SignatureHelp};
37
37
38pub struct EditorView {
38pub struct EditorView {
39 pub keymaps: Keymaps,
39 pub keymaps: Keymaps,
40− on_next_key: Option<Box<dyn FnOnce(&mut commands::Context, KeyEvent)>>,
40+ on_next_key: Option<OnKeyCallback>,
41 pseudo_pending: Vec<KeyEvent>,
41 pseudo_pending: Vec<KeyEvent>,
42 last_insert: (commands::MappableCommand, Vec<InsertEvent>),
42 last_insert: (commands::MappableCommand, Vec<InsertEvent>),
43 pub(crate) completion: Option<Completion>,
43 pub(crate) completion: Option<Completion>,
helix-term/src/ui/menu.rs+3−1
@@ -43,6 +43,8 @@ impl Item for PathBuf {
43 }
43 }
44}
44}
45
45
46+pub type MenuCallback<T> = Box<dyn Fn(&mut Editor, Option<&T>, MenuEvent)>;
47+
46pub struct Menu<T: Item> {
48pub struct Menu<T: Item> {
47 options: Vec<T>,
49 options: Vec<T>,
48 editor_data: T::Data,
50 editor_data: T::Data,
@@ -55,7 +57,7 @@ pub struct Menu<T: Item> {
55
57
56 widths: Vec<Constraint>,
58 widths: Vec<Constraint>,
57
59
58− callback_fn: Box<dyn Fn(&mut Editor, Option<&T>, MenuEvent)>,
60+ callback_fn: MenuCallback<T>,
59
61
60 scroll: usize,
62 scroll: usize,
61 size: (u16, u16),
63 size: (u16, u16),
helix-term/src/ui/picker.rs+6−2
@@ -70,6 +70,8 @@ impl From<DocumentId> for PathOrId {
70 }
70 }
71}
71}
72
72
73+type FileCallback<T> = Box<dyn Fn(&Editor, &T) -> Option<FileLocation>>;
74+
73/// File path and range of lines (used to align and highlight lines)
75/// File path and range of lines (used to align and highlight lines)
74pub type FileLocation = (PathOrId, Option<(usize, usize)>);
76pub type FileLocation = (PathOrId, Option<(usize, usize)>);
75
77
@@ -80,7 +82,7 @@ pub struct FilePicker<T: Item> {
80 preview_cache: HashMap<PathBuf, CachedPreview>,
82 preview_cache: HashMap<PathBuf, CachedPreview>,
81 read_buffer: Vec<u8>,
83 read_buffer: Vec<u8>,
82 /// Given an item in the picker, return the file path and line number to display.
84 /// Given an item in the picker, return the file path and line number to display.
83− file_fn: Box<dyn Fn(&Editor, &T) -> Option<FileLocation>>,
85+ file_fn: FileCallback<T>,
84}
86}
85
87
86pub enum CachedPreview {
88pub enum CachedPreview {
@@ -394,6 +396,8 @@ impl Ord for PickerMatch {
394 }
396 }
395}
397}
396
398
399+type PickerCallback<T> = Box<dyn Fn(&mut Context, &T, Action)>;
400+
397pub struct Picker<T: Item> {
401pub struct Picker<T: Item> {
398 options: Vec<T>,
402 options: Vec<T>,
399 editor_data: T::Data,
403 editor_data: T::Data,
@@ -415,7 +419,7 @@ pub struct Picker<T: Item> {
415 /// Constraints for tabular formatting
419 /// Constraints for tabular formatting
416 widths: Vec<Constraint>,
420 widths: Vec<Constraint>,
417
421
418− callback_fn: Box<dyn Fn(&mut Context, &T, Action)>,
422+ callback_fn: PickerCallback<T>,
419}
423}
420
424
421impl<T: Item> Picker<T> {
425impl<T: Item> Picker<T> {
helix-term/src/ui/prompt.rs+7−4
@@ -14,8 +14,11 @@ use helix_view::{
14 Editor,
14 Editor,
15};
15};
16
16
17−pub type Completion = (RangeFrom<usize>, Cow<'static, str>);
18type PromptCharHandler = Box<dyn Fn(&mut Prompt, char, &Context)>;
17type PromptCharHandler = Box<dyn Fn(&mut Prompt, char, &Context)>;
18+pub type Completion = (RangeFrom<usize>, Cow<'static, str>);
19+type CompletionFn = Box<dyn FnMut(&Editor, &str) -> Vec<Completion>>;
20+type CallbackFn = Box<dyn FnMut(&mut Context, &str, PromptEvent)>;
21+pub type DocFn = Box<dyn Fn(&str) -> Option<Cow<str>>>;
19
22
20pub struct Prompt {
23pub struct Prompt {
21 prompt: Cow<'static, str>,
24 prompt: Cow<'static, str>,
@@ -25,9 +28,9 @@ pub struct Prompt {
25 selection: Option<usize>,
28 selection: Option<usize>,
26 history_register: Option<char>,
29 history_register: Option<char>,
27 history_pos: Option<usize>,
30 history_pos: Option<usize>,
28− completion_fn: Box<dyn FnMut(&Editor, &str) -> Vec<Completion>>,
31+ completion_fn: CompletionFn,
29− callback_fn: Box<dyn FnMut(&mut Context, &str, PromptEvent)>,
32+ callback_fn: CallbackFn,
30− pub doc_fn: Box<dyn Fn(&str) -> Option<Cow<str>>>,
33+ pub doc_fn: DocFn,
31 next_char_handler: Option<PromptCharHandler>,
34 next_char_handler: Option<PromptCharHandler>,
32}
35}
33
36
rust-toolchain.toml+1−1
@@ -1,3 +1,3 @@
1[toolchain]
1[toolchain]
2−channel = "1.61.0"
2+channel = "1.63.0"
3components = ["rustfmt", "rust-src"]
3components = ["rustfmt", "rust-src"]