Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change the behavior of ui.cursor.insert and ui.cursor.select when ui.cursor.primary is present #2366

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
change the behavior of ui.cursor.{insert,select}
  • Loading branch information
oati committed May 18, 2022
commit a8cbde1f82cad4275d0e2020f2cf7e30c305ae96
23 changes: 16 additions & 7 deletions helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,25 @@ impl EditorView {
.find_scope_index("ui.cursor")
.unwrap_or(selection_scope);

let cursor_scope = match mode {
let mode_cursor_scope = match mode {
Mode::Insert => theme.find_scope_index("ui.cursor.insert"),
Mode::Select => theme.find_scope_index("ui.cursor.select"),
Mode::Normal => Some(base_cursor_scope),
}
.unwrap_or(base_cursor_scope);
Mode::Normal => None,
};

let cursor_scope = if theme.find_scope_index("ui.cursor.primary").is_some() {
base_cursor_scope
} else {
mode_cursor_scope.unwrap_or(base_cursor_scope)
};

let primary_cursor_scope =
if let Some(base_primary_cursor_scope) = theme.find_scope_index("ui.cursor.primary") {
mode_cursor_scope.unwrap_or(base_primary_cursor_scope)
} else {
cursor_scope
};
Comment on lines +327 to +338
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused by the conditionals here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this chooses between mode_cursor_scope and base_cursor_scope/base_primary_cursor_scope depending on whether ui.cursor.primary is present.

I'm considering making a new PR that cleans up the code to make all of the defaults and fallbacks clearer, and adding code for ui.cursor.{insert,select}.primary over it.


let primary_cursor_scope = theme
.find_scope_index("ui.cursor.primary")
.unwrap_or(cursor_scope);
let primary_selection_scope = theme
.find_scope_index("ui.selection.primary")
.unwrap_or(selection_scope);
Expand Down