pull/5695/head
Daniel Sedlak 2 years ago committed by GitHub
parent 1148ce1fd9
commit e856906f76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -109,7 +109,7 @@ pub fn visual_coords_at_pos(text: RopeSlice, pos: usize, tab_width: usize) -> Po
/// softwrapping positions are estimated with an O(1) algorithm /// softwrapping positions are estimated with an O(1) algorithm
/// to ensure consistent performance for large lines (currently unimplemented) /// to ensure consistent performance for large lines (currently unimplemented)
/// ///
/// Usualy you want to use `visual_offset_from_anchor` instead but this function /// Usually you want to use `visual_offset_from_anchor` instead but this function
/// can be useful (and faster) if /// can be useful (and faster) if
/// * You already know the visual position of the block /// * You already know the visual position of the block
/// * You only care about the horizontal offset (column) and not the vertical offset (row) /// * You only care about the horizontal offset (column) and not the vertical offset (row)
@ -291,7 +291,7 @@ pub fn pos_at_visual_coords(text: RopeSlice, coords: Position, tab_width: usize)
/// ///
/// If no (text) grapheme starts at exactly at the specified column the /// If no (text) grapheme starts at exactly at the specified column the
/// start of the grapheme to the left is returned. If there is no grapheme /// start of the grapheme to the left is returned. If there is no grapheme
/// to the left (for example if the line starts with virtual text) then the positiong /// to the left (for example if the line starts with virtual text) then the positioning
/// of the next grapheme to the right is returned. /// of the next grapheme to the right is returned.
/// ///
/// If the `line` coordinate is beyond the end of the file, the EOF /// If the `line` coordinate is beyond the end of the file, the EOF

@ -38,7 +38,7 @@ use std::borrow::Cow;
/// Ranges are considered to be inclusive on the left and /// Ranges are considered to be inclusive on the left and
/// exclusive on the right, regardless of anchor-head ordering. /// exclusive on the right, regardless of anchor-head ordering.
/// This means, for example, that non-zero-width ranges that /// This means, for example, that non-zero-width ranges that
/// are directly adjecent, sharing an edge, do not overlap. /// are directly adjacent, sharing an edge, do not overlap.
/// However, a zero-width range will overlap with the shared /// However, a zero-width range will overlap with the shared
/// left-edge of another range. /// left-edge of another range.
/// ///

@ -294,14 +294,14 @@ mod test {
#[test] #[test]
fn test_lists() { fn test_lists() {
let input = let input =
r#":set statusline.center ["file-type","file-encoding"] '["list", "in", "qoutes"]'"#; r#":set statusline.center ["file-type","file-encoding"] '["list", "in", "quotes"]'"#;
let shellwords = Shellwords::from(input); let shellwords = Shellwords::from(input);
let result = shellwords.words().to_vec(); let result = shellwords.words().to_vec();
let expected = vec![ let expected = vec![
Cow::from(":set"), Cow::from(":set"),
Cow::from("statusline.center"), Cow::from("statusline.center"),
Cow::from(r#"["file-type","file-encoding"]"#), Cow::from(r#"["file-type","file-encoding"]"#),
Cow::from(r#"["list", "in", "qoutes"]"#), Cow::from(r#"["list", "in", "quotes"]"#),
]; ];
assert_eq!(expected, result); assert_eq!(expected, result);
} }

@ -172,7 +172,7 @@ impl TextAnnotations {
for char_idx in char_range { for char_idx in char_range {
if let Some((_, Some(highlight))) = self.overlay_at(char_idx) { if let Some((_, Some(highlight))) = self.overlay_at(char_idx) {
// we don't know the number of chars the original grapheme takes // we don't know the number of chars the original grapheme takes
// however it doesn't matter as highlight bounderies are automatically // however it doesn't matter as highlight boundaries are automatically
// aligned to grapheme boundaries in the rendering code // aligned to grapheme boundaries in the rendering code
highlights.push((highlight.0, char_idx..char_idx + 1)) highlights.push((highlight.0, char_idx..char_idx + 1))
} }
@ -203,7 +203,7 @@ impl TextAnnotations {
/// Add new grapheme overlays. /// Add new grapheme overlays.
/// ///
/// The overlayed grapheme will be rendered with `highlight` /// The overlaid grapheme will be rendered with `highlight`
/// patched on top of `ui.text`. /// patched on top of `ui.text`.
/// ///
/// The overlays **must be sorted** by their `char_idx`. /// The overlays **must be sorted** by their `char_idx`.

@ -52,8 +52,8 @@ pub struct Client {
root_path: std::path::PathBuf, root_path: std::path::PathBuf,
root_uri: Option<lsp::Url>, root_uri: Option<lsp::Url>,
workspace_folders: Mutex<Vec<lsp::WorkspaceFolder>>, workspace_folders: Mutex<Vec<lsp::WorkspaceFolder>>,
initalize_notify: Arc<Notify>, initialize_notify: Arc<Notify>,
/// workspace folders added while the server is still initalizing /// workspace folders added while the server is still initializing
req_timeout: u64, req_timeout: u64,
} }
@ -92,14 +92,14 @@ impl Client {
return true; return true;
} }
// this server definitly doesn't support multiple workspace, no need to check capabilities // this server definitely doesn't support multiple workspace, no need to check capabilities
if !may_support_workspace { if !may_support_workspace {
return false; return false;
} }
let Some(capabilities) = self.capabilities.get() else { let Some(capabilities) = self.capabilities.get() else {
let client = Arc::clone(self); let client = Arc::clone(self);
// initalization hasn't finished yet, deal with this new root later // initialization hasn't finished yet, deal with this new root later
// TODO: In the edgecase that a **new root** is added // TODO: In the edgecase that a **new root** is added
// for an LSP that **doesn't support workspace_folders** before initaliation is finished // for an LSP that **doesn't support workspace_folders** before initaliation is finished
// the new roots are ignored. // the new roots are ignored.
@ -108,7 +108,7 @@ impl Client {
// documents LSP client handle. It's doable but a pretty weird edgecase so let's // documents LSP client handle. It's doable but a pretty weird edgecase so let's
// wait and see if anyone ever runs into it. // wait and see if anyone ever runs into it.
tokio::spawn(async move { tokio::spawn(async move {
client.initalize_notify.notified().await; client.initialize_notify.notified().await;
if let Some(workspace_folders_caps) = client if let Some(workspace_folders_caps) = client
.capabilities() .capabilities()
.workspace .workspace
@ -234,7 +234,7 @@ impl Client {
root_path, root_path,
root_uri, root_uri,
workspace_folders: Mutex::new(workspace_folders), workspace_folders: Mutex::new(workspace_folders),
initalize_notify: initialize_notify.clone(), initialize_notify: initialize_notify.clone(),
}; };
Ok((client, server_rx, initialize_notify)) Ok((client, server_rx, initialize_notify))
@ -279,7 +279,7 @@ impl Client {
"utf-16" => Some(OffsetEncoding::Utf16), "utf-16" => Some(OffsetEncoding::Utf16),
"utf-32" => Some(OffsetEncoding::Utf32), "utf-32" => Some(OffsetEncoding::Utf32),
encoding => { encoding => {
log::error!("Server provided invalid position encording {encoding}, defaulting to utf-16"); log::error!("Server provided invalid position encoding {encoding}, defaulting to utf-16");
None None
}, },
}) })

@ -152,10 +152,10 @@ pub mod util {
// > \n, \r\n and \r. Positions are line end character agnostic. // > \n, \r\n and \r. Positions are line end character agnostic.
// > So you can not specify a position that denotes \r|\n or \n| where | represents the character offset. // > So you can not specify a position that denotes \r|\n or \n| where | represents the character offset.
// //
// This means that while the line must be in bounds the `charater` // This means that while the line must be in bounds the `character`
// must be capped to the end of the line. // must be capped to the end of the line.
// Note that the end of the line here is **before** the line terminator // Note that the end of the line here is **before** the line terminator
// so we must use `line_end_char_index` istead of `doc.line_to_char(pos_line + 1)` // so we must use `line_end_char_index` instead of `doc.line_to_char(pos_line + 1)`
// //
// FIXME: Helix does not fully comply with the LSP spec for line terminators. // FIXME: Helix does not fully comply with the LSP spec for line terminators.
// The LSP standard requires that line terminators are ['\n', '\r\n', '\r']. // The LSP standard requires that line terminators are ['\n', '\r\n', '\r'].
@ -893,7 +893,7 @@ fn start_client(
/// * if the file is outside `workspace` return `None` /// * if the file is outside `workspace` return `None`
/// * start at `file` and search the file tree upward /// * start at `file` and search the file tree upward
/// * stop the search at the first `root_dirs` entry that contains `file` /// * stop the search at the first `root_dirs` entry that contains `file`
/// * if no `root_dirs` matchs `file` stop at workspace /// * if no `root_dirs` matches `file` stop at workspace
/// * Returns the top most directory that contains a `root_marker` /// * Returns the top most directory that contains a `root_marker`
/// * If no root marker and we stopped at a `root_dirs` entry, return the directory we stopped at /// * If no root marker and we stopped at a `root_dirs` entry, return the directory we stopped at
/// * If we stopped at `workspace` instead and `workspace_is_cwd == false` return `None` /// * If we stopped at `workspace` instead and `workspace_is_cwd == false` return `None`

@ -61,7 +61,7 @@ fn render_elements(
offset: &mut usize, offset: &mut usize,
tabstops: &mut Vec<(usize, (usize, usize))>, tabstops: &mut Vec<(usize, (usize, usize))>,
newline_with_offset: &str, newline_with_offset: &str,
include_placeholer: bool, include_placeholder: bool,
) { ) {
use SnippetElement::*; use SnippetElement::*;
@ -89,7 +89,7 @@ fn render_elements(
offset, offset,
tabstops, tabstops,
newline_with_offset, newline_with_offset,
include_placeholer, include_placeholder,
); );
} }
&Tabstop { tabstop } => { &Tabstop { tabstop } => {
@ -100,14 +100,14 @@ fn render_elements(
value: inner_snippet_elements, value: inner_snippet_elements,
} => { } => {
let start_offset = *offset; let start_offset = *offset;
if include_placeholer { if include_placeholder {
render_elements( render_elements(
inner_snippet_elements, inner_snippet_elements,
insert, insert,
offset, offset,
tabstops, tabstops,
newline_with_offset, newline_with_offset,
include_placeholer, include_placeholder,
); );
} }
tabstops.push((*tabstop, (start_offset, *offset))); tabstops.push((*tabstop, (start_offset, *offset)));
@ -127,7 +127,7 @@ fn render_elements(
pub fn render( pub fn render(
snippet: &Snippet<'_>, snippet: &Snippet<'_>,
newline_with_offset: &str, newline_with_offset: &str,
include_placeholer: bool, include_placeholder: bool,
) -> (Tendril, Vec<SmallVec<[(usize, usize); 1]>>) { ) -> (Tendril, Vec<SmallVec<[(usize, usize); 1]>>) {
let mut insert = Tendril::new(); let mut insert = Tendril::new();
let mut tabstops = Vec::new(); let mut tabstops = Vec::new();
@ -139,7 +139,7 @@ pub fn render(
&mut offset, &mut offset,
&mut tabstops, &mut tabstops,
newline_with_offset, newline_with_offset,
include_placeholer, include_placeholder,
); );
// sort in ascending order (except for 0, which should always be the last one (per lsp doc)) // sort in ascending order (except for 0, which should always be the last one (per lsp doc))

@ -25,7 +25,7 @@ use crate::{
config::Config, config::Config,
job::Jobs, job::Jobs,
keymap::Keymaps, keymap::Keymaps,
ui::{self, overlay::overlayed}, ui::{self, overlay::overlaid},
}; };
use log::{debug, error, warn}; use log::{debug, error, warn};
@ -169,7 +169,7 @@ impl Application {
std::env::set_current_dir(first).context("set current dir")?; std::env::set_current_dir(first).context("set current dir")?;
editor.new_file(Action::VerticalSplit); editor.new_file(Action::VerticalSplit);
let picker = ui::file_picker(".".into(), &config.load().editor); let picker = ui::file_picker(".".into(), &config.load().editor);
compositor.push(Box::new(overlayed(picker))); compositor.push(Box::new(overlaid(picker)));
} else { } else {
let nr_of_files = args.files.len(); let nr_of_files = args.files.len();
for (i, (file, pos)) in args.files.into_iter().enumerate() { for (i, (file, pos)) in args.files.into_iter().enumerate() {

@ -54,7 +54,7 @@ use crate::{
job::Callback, job::Callback,
keymap::ReverseKeymap, keymap::ReverseKeymap,
ui::{ ui::{
self, editor::InsertEvent, lsp::SignatureHelp, overlay::overlayed, FilePicker, Picker, self, editor::InsertEvent, lsp::SignatureHelp, overlay::overlaid, FilePicker, Picker,
Popup, Prompt, PromptEvent, Popup, Prompt, PromptEvent,
}, },
}; };
@ -1561,7 +1561,7 @@ fn half_page_down(cx: &mut Context) {
} }
#[allow(deprecated)] #[allow(deprecated)]
// currently uses the deprected `visual_coords_at_pos`/`pos_at_visual_coords` functions // currently uses the deprecated `visual_coords_at_pos`/`pos_at_visual_coords` functions
// as this function ignores softwrapping (and virtual text) and instead only cares // as this function ignores softwrapping (and virtual text) and instead only cares
// about "text visual position" // about "text visual position"
// //
@ -2147,7 +2147,7 @@ fn global_search(cx: &mut Context) {
Some((path.clone().into(), Some((*line_num, *line_num)))) Some((path.clone().into(), Some((*line_num, *line_num))))
}, },
); );
compositor.push(Box::new(overlayed(picker))); compositor.push(Box::new(overlaid(picker)));
}, },
)); ));
Ok(call) Ok(call)
@ -2421,7 +2421,7 @@ fn append_mode(cx: &mut Context) {
fn file_picker(cx: &mut Context) { fn file_picker(cx: &mut Context) {
let root = find_workspace().0; let root = find_workspace().0;
let picker = ui::file_picker(root, &cx.editor.config()); let picker = ui::file_picker(root, &cx.editor.config());
cx.push_layer(Box::new(overlayed(picker))); cx.push_layer(Box::new(overlaid(picker)));
} }
fn file_picker_in_current_buffer_directory(cx: &mut Context) { fn file_picker_in_current_buffer_directory(cx: &mut Context) {
@ -2438,12 +2438,12 @@ fn file_picker_in_current_buffer_directory(cx: &mut Context) {
}; };
let picker = ui::file_picker(path, &cx.editor.config()); let picker = ui::file_picker(path, &cx.editor.config());
cx.push_layer(Box::new(overlayed(picker))); cx.push_layer(Box::new(overlaid(picker)));
} }
fn file_picker_in_current_directory(cx: &mut Context) { fn file_picker_in_current_directory(cx: &mut Context) {
let cwd = std::env::current_dir().unwrap_or_else(|_| PathBuf::from("./")); let cwd = std::env::current_dir().unwrap_or_else(|_| PathBuf::from("./"));
let picker = ui::file_picker(cwd, &cx.editor.config()); let picker = ui::file_picker(cwd, &cx.editor.config());
cx.push_layer(Box::new(overlayed(picker))); cx.push_layer(Box::new(overlaid(picker)));
} }
fn buffer_picker(cx: &mut Context) { fn buffer_picker(cx: &mut Context) {
@ -2508,7 +2508,7 @@ fn buffer_picker(cx: &mut Context) {
Some((meta.id.into(), Some((line, line)))) Some((meta.id.into(), Some((line, line))))
}, },
); );
cx.push_layer(Box::new(overlayed(picker))); cx.push_layer(Box::new(overlaid(picker)));
} }
fn jumplist_picker(cx: &mut Context) { fn jumplist_picker(cx: &mut Context) {
@ -2590,7 +2590,7 @@ fn jumplist_picker(cx: &mut Context) {
Some((meta.path.clone()?.into(), Some((line, line)))) Some((meta.path.clone()?.into(), Some((line, line))))
}, },
); );
cx.push_layer(Box::new(overlayed(picker))); cx.push_layer(Box::new(overlaid(picker)));
} }
impl ui::menu::Item for MappableCommand { impl ui::menu::Item for MappableCommand {
@ -2664,7 +2664,7 @@ pub fn command_palette(cx: &mut Context) {
} }
} }
}); });
compositor.push(Box::new(overlayed(picker))); compositor.push(Box::new(overlaid(picker)));
}, },
)); ));
} }
@ -4185,7 +4185,7 @@ pub fn completion(cx: &mut Context) {
None => return, None => return,
}; };
// setup a chanel that allows the request to be canceled // setup a channel that allows the request to be canceled
let (tx, rx) = oneshot::channel(); let (tx, rx) = oneshot::channel();
// set completion_request so that this request can be canceled // set completion_request so that this request can be canceled
// by setting completion_request, the old channel stored there is dropped // by setting completion_request, the old channel stored there is dropped
@ -4238,7 +4238,7 @@ pub fn completion(cx: &mut Context) {
let (view, doc) = current_ref!(editor); let (view, doc) = current_ref!(editor);
// check if the completion request is stale. // check if the completion request is stale.
// //
// Completions are completed asynchrounsly and therefore the user could // Completions are completed asynchronously and therefore the user could
//switch document/view or leave insert mode. In all of thoise cases the //switch document/view or leave insert mode. In all of thoise cases the
// completion should be discarded // completion should be discarded
if editor.mode != Mode::Insert || view.id != trigger_view || doc.id() != trigger_doc { if editor.mode != Mode::Insert || view.id != trigger_view || doc.id() != trigger_doc {

@ -2,7 +2,7 @@ use super::{Context, Editor};
use crate::{ use crate::{
compositor::{self, Compositor}, compositor::{self, Compositor},
job::{Callback, Jobs}, job::{Callback, Jobs},
ui::{self, overlay::overlayed, FilePicker, Picker, Popup, Prompt, PromptEvent, Text}, ui::{self, overlay::overlaid, FilePicker, Picker, Popup, Prompt, PromptEvent, Text},
}; };
use dap::{StackFrame, Thread, ThreadStates}; use dap::{StackFrame, Thread, ThreadStates};
use helix_core::syntax::{DebugArgumentValue, DebugConfigCompletion, DebugTemplate}; use helix_core::syntax::{DebugArgumentValue, DebugConfigCompletion, DebugTemplate};
@ -270,7 +270,7 @@ pub fn dap_launch(cx: &mut Context) {
let templates = config.templates.clone(); let templates = config.templates.clone();
cx.push_layer(Box::new(overlayed(Picker::new( cx.push_layer(Box::new(overlaid(Picker::new(
templates, templates,
(), (),
|cx, template, _action| { |cx, template, _action| {

@ -26,7 +26,7 @@ use helix_view::{
use crate::{ use crate::{
compositor::{self, Compositor}, compositor::{self, Compositor},
ui::{ ui::{
self, lsp::SignatureHelp, overlay::overlayed, DynamicPicker, FileLocation, FilePicker, self, lsp::SignatureHelp, overlay::overlaid, DynamicPicker, FileLocation, FilePicker,
Popup, PromptEvent, Popup, PromptEvent,
}, },
}; };
@ -372,7 +372,7 @@ pub fn symbol_picker(cx: &mut Context) {
}; };
let picker = sym_picker(symbols, current_url, offset_encoding); let picker = sym_picker(symbols, current_url, offset_encoding);
compositor.push(Box::new(overlayed(picker))) compositor.push(Box::new(overlaid(picker)))
} }
}, },
) )
@ -431,7 +431,7 @@ pub fn workspace_symbol_picker(cx: &mut Context) {
future.boxed() future.boxed()
}; };
let dyn_picker = DynamicPicker::new(picker, Box::new(get_symbols)); let dyn_picker = DynamicPicker::new(picker, Box::new(get_symbols));
compositor.push(Box::new(overlayed(dyn_picker))) compositor.push(Box::new(overlaid(dyn_picker)))
}, },
) )
} }
@ -454,7 +454,7 @@ pub fn diagnostics_picker(cx: &mut Context) {
DiagnosticsFormat::HideSourcePath, DiagnosticsFormat::HideSourcePath,
offset_encoding, offset_encoding,
); );
cx.push_layer(Box::new(overlayed(picker))); cx.push_layer(Box::new(overlaid(picker)));
} }
} }
@ -471,7 +471,7 @@ pub fn workspace_diagnostics_picker(cx: &mut Context) {
DiagnosticsFormat::ShowSourcePath, DiagnosticsFormat::ShowSourcePath,
offset_encoding, offset_encoding,
); );
cx.push_layer(Box::new(overlayed(picker))); cx.push_layer(Box::new(overlaid(picker)));
} }
impl ui::menu::Item for lsp::CodeActionOrCommand { impl ui::menu::Item for lsp::CodeActionOrCommand {
@ -491,7 +491,7 @@ impl ui::menu::Item for lsp::CodeActionOrCommand {
/// ///
/// While the `kind` field is defined as open ended in the LSP spec (any value may be used) /// While the `kind` field is defined as open ended in the LSP spec (any value may be used)
/// in practice a closed set of common values (mostly suggested in the LSP spec) are used. /// in practice a closed set of common values (mostly suggested in the LSP spec) are used.
/// VSCode displays each of these categories seperatly (seperated by a heading in the codeactions picker) /// VSCode displays each of these categories separately (separated by a heading in the codeactions picker)
/// to make them easier to navigate. Helix does not display these headings to the user. /// to make them easier to navigate. Helix does not display these headings to the user.
/// However it does sort code actions by their categories to achieve the same order as the VScode picker, /// However it does sort code actions by their categories to achieve the same order as the VScode picker,
/// just without the headings. /// just without the headings.
@ -521,7 +521,7 @@ fn action_category(action: &CodeActionOrCommand) -> u32 {
} }
} }
fn action_prefered(action: &CodeActionOrCommand) -> bool { fn action_preferred(action: &CodeActionOrCommand) -> bool {
matches!( matches!(
action, action,
CodeActionOrCommand::CodeAction(CodeAction { CodeActionOrCommand::CodeAction(CodeAction {
@ -600,12 +600,12 @@ pub fn code_action(cx: &mut Context) {
} }
// Sort codeactions into a useful order. This behaviour is only partially described in the LSP spec. // Sort codeactions into a useful order. This behaviour is only partially described in the LSP spec.
// Many details are modeled after vscode because langauge servers are usually tested against it. // Many details are modeled after vscode because language servers are usually tested against it.
// VScode sorts the codeaction two times: // VScode sorts the codeaction two times:
// //
// First the codeactions that fix some diagnostics are moved to the front. // First the codeactions that fix some diagnostics are moved to the front.
// If both codeactions fix some diagnostics (or both fix none) the codeaction // If both codeactions fix some diagnostics (or both fix none) the codeaction
// that is marked with `is_preffered` is shown first. The codeactions are then shown in seperate // that is marked with `is_preferred` is shown first. The codeactions are then shown in separate
// submenus that only contain a certain category (see `action_category`) of actions. // submenus that only contain a certain category (see `action_category`) of actions.
// //
// Below this done in in a single sorting step // Below this done in in a single sorting step
@ -627,10 +627,10 @@ pub fn code_action(cx: &mut Context) {
return order; return order;
} }
// if one of the codeactions is marked as prefered show it first // if one of the codeactions is marked as preferred show it first
// otherwise keep the original LSP sorting // otherwise keep the original LSP sorting
action_prefered(action1) action_preferred(action1)
.cmp(&action_prefered(action2)) .cmp(&action_preferred(action2))
.reverse() .reverse()
}); });
@ -955,7 +955,7 @@ fn goto_impl(
}, },
move |_editor, location| Some(location_to_file_location(location)), move |_editor, location| Some(location_to_file_location(location)),
); );
compositor.push(Box::new(overlayed(picker))); compositor.push(Box::new(overlaid(picker)));
} }
} }
} }

@ -116,7 +116,7 @@ fn open(cx: &mut compositor::Context, args: &[Cow<str>], event: PromptEvent) ->
let call: job::Callback = job::Callback::EditorCompositor(Box::new( let call: job::Callback = job::Callback::EditorCompositor(Box::new(
move |editor: &mut Editor, compositor: &mut Compositor| { move |editor: &mut Editor, compositor: &mut Compositor| {
let picker = ui::file_picker(path, &editor.config()); let picker = ui::file_picker(path, &editor.config());
compositor.push(Box::new(overlayed(picker))); compositor.push(Box::new(overlaid(picker)));
}, },
)); ));
Ok(call) Ok(call)
@ -1335,7 +1335,7 @@ fn lsp_workspace_command(
let picker = ui::Picker::new(commands, (), |cx, command, _action| { let picker = ui::Picker::new(commands, (), |cx, command, _action| {
execute_lsp_command(cx.editor, command.clone()); execute_lsp_command(cx.editor, command.clone());
}); });
compositor.push(Box::new(overlayed(picker))) compositor.push(Box::new(overlaid(picker)))
}, },
)); ));
Ok(call) Ok(call)

@ -118,7 +118,7 @@ pub fn render_document(
fn translate_positions( fn translate_positions(
char_pos: usize, char_pos: usize,
first_visisble_char_idx: usize, first_visible_char_idx: usize,
translated_positions: &mut [TranslatedPosition], translated_positions: &mut [TranslatedPosition],
text_fmt: &TextFormat, text_fmt: &TextFormat,
renderer: &mut TextRenderer, renderer: &mut TextRenderer,
@ -126,7 +126,7 @@ fn translate_positions(
) { ) {
// check if any positions translated on the fly (like cursor) has been reached // check if any positions translated on the fly (like cursor) has been reached
for (char_idx, callback) in &mut *translated_positions { for (char_idx, callback) in &mut *translated_positions {
if *char_idx < char_pos && *char_idx >= first_visisble_char_idx { if *char_idx < char_pos && *char_idx >= first_visible_char_idx {
// by replacing the char_index with usize::MAX large number we ensure // by replacing the char_index with usize::MAX large number we ensure
// that the same position is only translated once // that the same position is only translated once
// text will never reach usize::MAX as rust memory allocations are limited // text will never reach usize::MAX as rust memory allocations are limited
@ -259,7 +259,7 @@ pub fn render_text<'t>(
} }
} }
// aquire the correct grapheme style // acquire the correct grapheme style
if char_pos >= style_span.1 { if char_pos >= style_span.1 {
style_span = styles.next().unwrap_or((Style::default(), usize::MAX)); style_span = styles.next().unwrap_or((Style::default(), usize::MAX));
} }
@ -404,7 +404,7 @@ impl<'a> TextRenderer<'a> {
let cut_off_start = self.col_offset.saturating_sub(position.col); let cut_off_start = self.col_offset.saturating_sub(position.col);
let is_whitespace = grapheme.is_whitespace(); let is_whitespace = grapheme.is_whitespace();
// TODO is it correct to apply the whitspace style to all unicode white spaces? // TODO is it correct to apply the whitespace style to all unicode white spaces?
if is_whitespace { if is_whitespace {
style = style.patch(self.whitespace_style); style = style.patch(self.whitespace_style);
} }

@ -54,7 +54,7 @@ impl QueryAtom {
} }
fn indices(&self, matcher: &Matcher, item: &str, indices: &mut Vec<usize>) -> bool { fn indices(&self, matcher: &Matcher, item: &str, indices: &mut Vec<usize>) -> bool {
// for inverse there are no indicies to return // for inverse there are no indices to return
// just return whether we matched // just return whether we matched
if self.inverse { if self.inverse {
return self.matches(matcher, item); return self.matches(matcher, item);
@ -120,7 +120,7 @@ enum QueryAtomKind {
/// ///
/// Usage: `foo` /// Usage: `foo`
Fuzzy, Fuzzy,
/// Item contains query atom as a continous substring /// Item contains query atom as a continuous substring
/// ///
/// Usage `'foo` /// Usage `'foo`
Substring, Substring,
@ -213,7 +213,7 @@ impl FuzzyQuery {
Some(score) Some(score)
} }
pub fn fuzzy_indicies(&self, item: &str, matcher: &Matcher) -> Option<(i64, Vec<usize>)> { pub fn fuzzy_indices(&self, item: &str, matcher: &Matcher) -> Option<(i64, Vec<usize>)> {
let (score, mut indices) = self.first_fuzzy_atom.as_ref().map_or_else( let (score, mut indices) = self.first_fuzzy_atom.as_ref().map_or_else(
|| Some((0, Vec::new())), || Some((0, Vec::new())),
|atom| matcher.fuzzy_indices(item, atom), |atom| matcher.fuzzy_indices(item, atom),

@ -7,8 +7,8 @@ fn run_test<'a>(query: &str, items: &'a [&'a str]) -> Vec<String> {
items items
.iter() .iter()
.filter_map(|item| { .filter_map(|item| {
let (_, indicies) = query.fuzzy_indicies(item, &matcher)?; let (_, indices) = query.fuzzy_indices(item, &matcher)?;
let matched_string = indicies let matched_string = indices
.iter() .iter()
.map(|&pos| item.chars().nth(pos).unwrap()) .map(|&pos| item.chars().nth(pos).unwrap())
.collect(); .collect();

@ -16,7 +16,7 @@ pub struct Overlay<T> {
} }
/// Surrounds the component with a margin of 5% on each side, and an additional 2 rows at the bottom /// Surrounds the component with a margin of 5% on each side, and an additional 2 rows at the bottom
pub fn overlayed<T>(content: T) -> Overlay<T> { pub fn overlaid<T>(content: T) -> Overlay<T> {
Overlay { Overlay {
content, content,
calc_child_size: Box::new(|rect: Rect| clip_rect_relative(rect.clip_bottom(2), 90, 90)), calc_child_size: Box::new(|rect: Rect| clip_rect_relative(rect.clip_bottom(2), 90, 90)),

@ -794,7 +794,7 @@ impl<T: Item + 'static> Component for Picker<T> {
// might be inconsistencies. This is the best we can do since only the // might be inconsistencies. This is the best we can do since only the
// text in Row is displayed to the end user. // text in Row is displayed to the end user.
let (_score, highlights) = FuzzyQuery::new(self.prompt.line()) let (_score, highlights) = FuzzyQuery::new(self.prompt.line())
.fuzzy_indicies(&line, &self.matcher) .fuzzy_indices(&line, &self.matcher)
.unwrap_or_default(); .unwrap_or_default();
let highlight_byte_ranges: Vec<_> = line let highlight_byte_ranges: Vec<_> = line

@ -391,7 +391,7 @@ async fn cursor_position_newly_opened_file() -> anyhow::Result<()> {
#[tokio::test(flavor = "multi_thread")] #[tokio::test(flavor = "multi_thread")]
async fn cursor_position_append_eof() -> anyhow::Result<()> { async fn cursor_position_append_eof() -> anyhow::Result<()> {
// Selection is fowards // Selection is forwards
test(( test((
"#[foo|]#", "#[foo|]#",
"abar<esc>", "abar<esc>",

@ -344,9 +344,9 @@ impl ModifierDiff {
} }
} }
/// Crossterm uses semicolon as a seperator for colors /// Crossterm uses semicolon as a separator for colors
/// this is actually not spec compliant (altough commonly supported) /// this is actually not spec compliant (although commonly supported)
/// However the correct approach is to use colons as a seperator. /// However the correct approach is to use colons as a separator.
/// This usually doesn't make a difference for emulators that do support colored underlines. /// This usually doesn't make a difference for emulators that do support colored underlines.
/// However terminals that do not support colored underlines will ignore underlines colors with colons /// However terminals that do not support colored underlines will ignore underlines colors with colons
/// while escape sequences with semicolons are always processed which leads to weird visual artifacts. /// while escape sequences with semicolons are always processed which leads to weird visual artifacts.

@ -851,7 +851,7 @@ pub struct Editor {
pub config_events: (UnboundedSender<ConfigEvent>, UnboundedReceiver<ConfigEvent>), pub config_events: (UnboundedSender<ConfigEvent>, UnboundedReceiver<ConfigEvent>),
/// Allows asynchronous tasks to control the rendering /// Allows asynchronous tasks to control the rendering
/// The `Notify` allows asynchronous tasks to request the editor to perform a redraw /// The `Notify` allows asynchronous tasks to request the editor to perform a redraw
/// The `RwLock` blocks the editor from performing the render until an exclusive lock can be aquired /// The `RwLock` blocks the editor from performing the render until an exclusive lock can be acquired
pub redraw_handle: RedrawHandle, pub redraw_handle: RedrawHandle,
pub needs_redraw: bool, pub needs_redraw: bool,
/// Cached position of the cursor calculated during rendering. /// Cached position of the cursor calculated during rendering.

@ -128,7 +128,7 @@ impl Loader {
let parent_palette = parent_theme_toml.get("palette"); let parent_palette = parent_theme_toml.get("palette");
let palette = theme_toml.get("palette"); let palette = theme_toml.get("palette");
// handle the table seperately since it needs a `merge_depth` of 2 // handle the table separately since it needs a `merge_depth` of 2
// this would conflict with the rest of the theme merge strategy // this would conflict with the rest of the theme merge strategy
let palette_values = match (parent_palette, palette) { let palette_values = match (parent_palette, palette) {
(Some(parent_palette), Some(palette)) => { (Some(parent_palette), Some(palette)) => {

Loading…
Cancel
Save