-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
simpler file modification indicator #2831
Changes from all commits
ca3e9d9
d4de7df
8541417
62c2bc5
65fdbc3
f66fd2f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,8 @@ use grep_searcher::{sinks, BinaryDetection, SearcherBuilder}; | |
use ignore::{DirEntry, WalkBuilder, WalkState}; | ||
use tokio_stream::wrappers::UnboundedReceiverStream; | ||
|
||
const DEFAULT_CURRENT_BUFFER_INDICATOR: &str = "*"; | ||
|
||
pub struct Context<'a> { | ||
pub register: Option<char>, | ||
pub count: Option<NonZeroUsize>, | ||
|
@@ -2208,6 +2210,8 @@ fn buffer_picker(cx: &mut Context) { | |
path: Option<PathBuf>, | ||
is_modified: bool, | ||
is_current: bool, | ||
modified_indicator: String, | ||
current_indicator: String, | ||
} | ||
|
||
impl ui::menu::Item for BufferMeta { | ||
|
@@ -2225,10 +2229,10 @@ fn buffer_picker(cx: &mut Context) { | |
|
||
let mut flags = Vec::new(); | ||
if self.is_modified { | ||
flags.push("+"); | ||
flags.push(self.modified_indicator.to_string()); | ||
} | ||
if self.is_current { | ||
flags.push("*"); | ||
flags.push(self.current_indicator.to_string()); | ||
Comment on lines
+2232
to
+2235
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just push There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we do this then we have to modify the |
||
} | ||
|
||
let flag = if flags.is_empty() { | ||
|
@@ -2245,6 +2249,8 @@ fn buffer_picker(cx: &mut Context) { | |
path: doc.path().cloned(), | ||
is_modified: doc.is_modified(), | ||
is_current: doc.id() == current, | ||
modified_indicator: cx.editor.config().file_modification_indicator.clone(), | ||
current_indicator: DEFAULT_CURRENT_BUFFER_INDICATOR.to_string(), | ||
Comment on lines
+2252
to
+2253
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, this is going to be a bunch of allocations per document on the list... Is customizability here really that necessary? From what I can tell vim simply always uses There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Could you explain this further? isn't it just one (few-byte) string allocation per open document? As far as I can tell it's mapped to open documents on line 2260 and only in the buffer picker, but I'm undoubtedly missing something.
It's certainly not necessary, but it's a nice quality-of-life that I miss from my existing nvim setup that shouldn't impact too many people. (I use a It also gets const strings out of the middle of multiple code blocks and centralized, which I think is very important. Right now if you want to change a symbol there are multiple places you need to go to do it. |
||
}; | ||
|
||
let picker = FilePicker::new( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this changes how the default looks: we used
+
but instead[+]
will be used nowThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - this requires some discussion (c.f. #2831 (comment))