Skip to content

Commit

Permalink
Update to rust 1.56 + 2021 edition
Browse files Browse the repository at this point in the history
  • Loading branch information
archseer committed Oct 22, 2021
1 parent 3b032e8 commit 182a59b
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 56 deletions.
68 changes: 52 additions & 16 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
nixCargoIntegration = {
url = "github:yusdacra/nix-cargo-integration";
inputs.nixpkgs.follows = "nixpkgs";
inputs.rustOverlay.follows = "rust-overlay";
};
flakeCompat = {
url = "github:edolstra/flake-compat";
Expand Down
2 changes: 1 addition & 1 deletion helix-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "helix-core"
version = "0.4.1"
authors = ["Blaž Hrastnik <blaz@mxxn.io>"]
edition = "2018"
edition = "2021"
license = "MPL-2.0"
description = "Helix editor core editing primitives"
categories = ["editor"]
Expand Down
2 changes: 1 addition & 1 deletion helix-lsp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "helix-lsp"
version = "0.4.1"
authors = ["Blaž Hrastnik <blaz@mxxn.io>"]
edition = "2018"
edition = "2021"
license = "MPL-2.0"
description = "LSP client implementation for Helix project"
categories = ["editor"]
Expand Down
2 changes: 1 addition & 1 deletion helix-syntax/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "helix-syntax"
version = "0.4.1"
authors = ["Blaž Hrastnik <blaz@mxxn.io>"]
edition = "2018"
edition = "2021"
license = "MPL-2.0"
description = "Tree-sitter grammars support"
categories = ["editor"]
Expand Down
2 changes: 1 addition & 1 deletion helix-term/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "helix-term"
version = "0.4.1"
description = "A post-modern text editor."
authors = ["Blaž Hrastnik <blaz@mxxn.io>"]
edition = "2018"
edition = "2021"
license = "MPL-2.0"
categories = ["editor", "command-line-utilities"]
repository = "https://github.com/helix-editor/helix"
Expand Down
32 changes: 15 additions & 17 deletions helix-term/src/ui/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,23 @@ impl<T: Item> Menu<T> {
}

pub fn score(&mut self, pattern: &str) {
// need to borrow via pattern match otherwise it complains about simultaneous borrow
let Self {
ref mut matcher,
ref mut matches,
ref options,
..
} = *self;

// reuse the matches allocation
matches.clear();
matches.extend(options.iter().enumerate().filter_map(|(index, option)| {
let text = option.filter_text();
// TODO: using fuzzy_indices could give us the char idx for match highlighting
matcher
.fuzzy_match(text, pattern)
.map(|score| (index, score))
}));
self.matches.clear();
self.matches.extend(
self.options
.iter()
.enumerate()
.filter_map(|(index, option)| {
let text = option.filter_text();
// TODO: using fuzzy_indices could give us the char idx for match highlighting
self.matcher
.fuzzy_match(text, pattern)
.map(|score| (index, score))
}),
);
// matches.sort_unstable_by_key(|(_, score)| -score);
matches.sort_unstable_by_key(|(index, _score)| options[*index].sort_text());
self.matches
.sort_unstable_by_key(|(index, _score)| self.options[*index].sort_text());

// reset cursor position
self.cursor = None;
Expand Down
23 changes: 7 additions & 16 deletions helix-term/src/ui/picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,37 +233,28 @@ impl<T> Picker<T> {
}

pub fn score(&mut self) {
// need to borrow via pattern match otherwise it complains about simultaneous borrow
let Self {
ref mut matcher,
ref mut matches,
ref filters,
ref format_fn,
..
} = *self;

let pattern = &self.prompt.line;

// reuse the matches allocation
matches.clear();
matches.extend(
self.matches.clear();
self.matches.extend(
self.options
.iter()
.enumerate()
.filter_map(|(index, option)| {
// filter options first before matching
if !filters.is_empty() {
filters.binary_search(&index).ok()?;
if !self.filters.is_empty() {
self.filters.binary_search(&index).ok()?;
}
// TODO: maybe using format_fn isn't the best idea here
let text = (format_fn)(option);
let text = (self.format_fn)(option);
// TODO: using fuzzy_indices could give us the char idx for match highlighting
matcher
self.matcher
.fuzzy_match(&text, pattern)
.map(|score| (index, score))
}),
);
matches.sort_unstable_by_key(|(_, score)| -score);
self.matches.sort_unstable_by_key(|(_, score)| -score);

// reset cursor position
self.cursor = 0;
Expand Down
2 changes: 1 addition & 1 deletion helix-tui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Blaž Hrastnik <blaz@mxxn.io>"]
description = """
A library to build rich terminal user interfaces or dashboards
"""
edition = "2018"
edition = "2021"
license = "MPL-2.0"
categories = ["editor"]
repository = "https://github.com/helix-editor/helix"
Expand Down
2 changes: 1 addition & 1 deletion helix-view/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "helix-view"
version = "0.4.1"
authors = ["Blaž Hrastnik <blaz@mxxn.io>"]
edition = "2018"
edition = "2021"
license = "MPL-2.0"
description = "UI abstractions for use in backends"
categories = ["editor"]
Expand Down
1 change: 0 additions & 1 deletion helix-view/src/theme.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::{
collections::HashMap,
convert::TryFrom,
path::{Path, PathBuf},
};

Expand Down

0 comments on commit 182a59b

Please sign in to comment.