workspace: Improve save prompt. (#3025)

Add buffer path to the prompt.

Z-2903

Release Notes:
- Added a "Save all/Discard all" prompt when closing a pane with
multiple edited buffers.
This commit is contained in:
Piotr Osiewicz 2023-09-25 16:15:29 +02:00 committed by GitHub
parent 0697d08e54
commit 0a491e773b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 148 additions and 33 deletions

View file

@ -41,6 +41,8 @@ pub fn truncate(s: &str, max_chars: usize) -> &str {
}
}
/// Removes characters from the end of the string if it's length is greater than `max_chars` and
/// appends "..." to the string. Returns string unchanged if it's length is smaller than max_chars.
pub fn truncate_and_trailoff(s: &str, max_chars: usize) -> String {
debug_assert!(max_chars >= 5);
@ -51,6 +53,18 @@ pub fn truncate_and_trailoff(s: &str, max_chars: usize) -> String {
}
}
/// Removes characters from the front of the string if it's length is greater than `max_chars` and
/// prepends the string with "...". Returns string unchanged if it's length is smaller than max_chars.
pub fn truncate_and_remove_front(s: &str, max_chars: usize) -> String {
debug_assert!(max_chars >= 5);
let truncation_ix = s.char_indices().map(|(i, _)| i).nth_back(max_chars);
match truncation_ix {
Some(length) => "".to_string() + &s[length..],
None => s.to_string(),
}
}
pub fn post_inc<T: From<u8> + AddAssign<T> + Copy>(value: &mut T) -> T {
let prev = *value;
*value += T::from(1);