mirror of https://github.com/helix-editor/helix
Added command to differentiate duplicate names in bufferline
Refactored logic, uses HashMap for efficiency Changed conditionalpull/5092/head
parent
d14de27709
commit
57c990e280
|
@ -671,6 +671,9 @@ impl EditorView {
|
||||||
let mut x = viewport.x;
|
let mut x = viewport.x;
|
||||||
let current_doc = view!(editor).doc;
|
let current_doc = view!(editor).doc;
|
||||||
|
|
||||||
|
use std::collections::HashMap;
|
||||||
|
let mut names_map: HashMap<&str, usize> = HashMap::new();
|
||||||
|
|
||||||
for doc in editor.documents() {
|
for doc in editor.documents() {
|
||||||
let fname = doc
|
let fname = doc
|
||||||
.path()
|
.path()
|
||||||
|
@ -680,6 +683,28 @@ impl EditorView {
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
|
if names_map.contains_key(fname) {
|
||||||
|
names_map.insert(fname, names_map.get(fname).unwrap() + 1);
|
||||||
|
} else {
|
||||||
|
names_map.insert(fname, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for doc in editor.documents() {
|
||||||
|
let mut fname = doc
|
||||||
|
.path()
|
||||||
|
.unwrap_or(&scratch)
|
||||||
|
.file_name()
|
||||||
|
.unwrap_or_default()
|
||||||
|
.to_str()
|
||||||
|
.unwrap_or_default();
|
||||||
|
|
||||||
|
let rel_path = doc.relative_path().unwrap_or_default();
|
||||||
|
|
||||||
|
if *names_map.get(fname).unwrap() > 1 {
|
||||||
|
fname = rel_path.to_str().unwrap_or_default();
|
||||||
|
}
|
||||||
|
|
||||||
let style = if current_doc == doc.id() {
|
let style = if current_doc == doc.id() {
|
||||||
bufferline_active
|
bufferline_active
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue