Compare commits

...

9 Commits

Author SHA1 Message Date
Max Brunsfeld
5c0083d4dd zed 0.62.2 2022-10-27 16:49:05 -07:00
Max Brunsfeld
85cb68c3f5 Merge pull request #1830 from zed-industries/auto-update-filename
Make auto-update handle an app bundle name other than 'Zed.app'
2022-10-27 16:48:42 -07:00
Max Brunsfeld
7aec6b5531 zed 0.62.1 2022-10-27 15:45:30 -07:00
Max Brunsfeld
4dab0f89f4 Tweak version-bumping scripts 2022-10-27 15:45:07 -07:00
Max Brunsfeld
d2f6b315a3 Avoid posting in Discord about preview releases (for now)
Co-authored-by: Joseph Lyons <joseph@zed.dev>
2022-10-27 15:44:32 -07:00
Kay Simmons
62d4473c3f Merge pull request #1827 from zed-industries/fix-keymap-resolution-fallback
Keymap resolution fallbacks
2022-10-27 15:44:05 -07:00
Max Brunsfeld
6e2d3aae68 Merge pull request #1828 from zed-industries/following-scrollbar
Show scrollbar when scrolling while following
2022-10-27 15:43:53 -07:00
Max Brunsfeld
e5959483ed Merge pull request #1825 from zed-industries/update-notification-release-channel
Indicate release channel in auto-update notification
2022-10-27 11:01:41 -07:00
Max Brunsfeld
e13012c48e Preview 0.62.x 2022-10-26 21:09:00 -07:00
18 changed files with 193 additions and 204 deletions

View File

@@ -8,6 +8,7 @@ jobs:
steps:
- name: Discord Webhook Action
uses: tsickert/discord-webhook@v5.3.0
if: ${{ ! github.event.release.prerelease }}
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
content: |

2
Cargo.lock generated
View File

@@ -7629,7 +7629,7 @@ dependencies = [
[[package]]
name = "zed"
version = "0.62.0"
version = "0.62.2"
dependencies = [
"activity_indicator",
"anyhow",

View File

@@ -218,11 +218,14 @@ impl AutoUpdater {
let temp_dir = tempdir::TempDir::new("zed-auto-update")?;
let dmg_path = temp_dir.path().join("Zed.dmg");
let mount_path = temp_dir.path().join("Zed");
let mut mounted_app_path: OsString = mount_path.join("Zed.app").into();
mounted_app_path.push("/");
let running_app_path = ZED_APP_PATH
.clone()
.map_or_else(|| cx.platform().app_path(), Ok)?;
let running_app_filename = running_app_path
.file_name()
.ok_or_else(|| anyhow!("invalid running app path"))?;
let mut mounted_app_path: OsString = mount_path.join(running_app_filename).into();
mounted_app_path.push("/");
let mut dmg_file = File::create(&dmg_path).await?;
let mut response = client.get(&release.url, Default::default(), true).await?;

View File

@@ -5,7 +5,7 @@ use gpui::{
Element, Entity, MouseButton, View, ViewContext,
};
use menu::Cancel;
use settings::Settings;
use settings::{ReleaseChannel, Settings};
use workspace::Notification;
pub struct UpdateNotification {
@@ -29,13 +29,19 @@ impl View for UpdateNotification {
let theme = cx.global::<Settings>().theme.clone();
let theme = &theme.update_notification;
let app_name = match *cx.global::<ReleaseChannel>() {
ReleaseChannel::Dev => "Zed Dev",
ReleaseChannel::Preview => "Zed Preview",
ReleaseChannel::Stable => "Zed",
};
MouseEventHandler::<ViewReleaseNotes>::new(0, cx, |state, cx| {
Flex::column()
.with_child(
Flex::row()
.with_child(
Text::new(
format!("Updated to Zed {}", self.version),
format!("Updated to {app_name} {}", self.version),
theme.message.text.clone(),
)
.contained()

View File

@@ -97,15 +97,9 @@ impl AmplitudeTelemetry {
.unwrap()
.as_millis(),
state: Mutex::new(AmplitudeTelemetryState {
os_version: platform
.os_version()
.log_err()
.map(|v| v.to_string().into()),
os_version: platform.os_version().ok().map(|v| v.to_string().into()),
os_name: platform.os_name().into(),
app_version: platform
.app_version()
.log_err()
.map(|v| v.to_string().into()),
app_version: platform.app_version().ok().map(|v| v.to_string().into()),
device_id: None,
queue: Default::default(),
flush_task: Default::default(),

View File

@@ -103,15 +103,9 @@ impl Telemetry {
http_client: client,
executor: cx.background().clone(),
state: Mutex::new(TelemetryState {
os_version: platform
.os_version()
.log_err()
.map(|v| v.to_string().into()),
os_version: platform.os_version().ok().map(|v| v.to_string().into()),
os_name: platform.os_name().into(),
app_version: platform
.app_version()
.log_err()
.map(|v| v.to_string().into()),
app_version: platform.app_version().ok().map(|v| v.to_string().into()),
device_id: None,
metrics_id: None,
queue: Default::default(),

View File

@@ -71,7 +71,6 @@ impl BlinkManager {
if epoch == self.blink_epoch && self.enabled && !self.blinking_paused {
self.visible = !self.visible;
cx.notify();
dbg!(cx.handle());
let epoch = self.next_blink_epoch();
let interval = self.blink_interval;

View File

@@ -1353,6 +1353,7 @@ impl Editor {
) {
self.scroll_top_anchor = anchor;
self.scroll_position = position;
self.make_scrollbar_visible(cx);
cx.emit(Event::ScrollPositionChanged { local: false });
cx.notify();
}

View File

@@ -1544,17 +1544,18 @@ impl MutableAppContext {
{
MatchResult::None => false,
MatchResult::Pending => true,
MatchResult::Match { view_id, action } => {
if self.handle_dispatch_action_from_effect(
window_id,
Some(view_id),
action.as_ref(),
) {
self.keystroke_matcher.clear_pending();
true
} else {
false
MatchResult::Matches(matches) => {
for (view_id, action) in matches {
if self.handle_dispatch_action_from_effect(
window_id,
Some(view_id),
action.as_ref(),
) {
self.keystroke_matcher.clear_pending();
return true;
}
}
false
}
}
} else {

View File

@@ -13,16 +13,11 @@ extern "C" {
}
pub struct Matcher {
pending: HashMap<usize, Pending>,
pending_views: HashMap<usize, Context>,
pending_keystrokes: Vec<Keystroke>,
keymap: Keymap,
}
#[derive(Default)]
struct Pending {
keystrokes: Vec<Keystroke>,
context: Option<Context>,
}
#[derive(Default)]
pub struct Keymap {
bindings: Vec<Binding>,
@@ -77,21 +72,21 @@ where
pub enum MatchResult {
None,
Pending,
Match {
view_id: usize,
action: Box<dyn Action>,
},
Matches(Vec<(usize, Box<dyn Action>)>),
}
impl Debug for MatchResult {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
MatchResult::None => f.debug_struct("MatchResult2::None").finish(),
MatchResult::Pending => f.debug_struct("MatchResult2::Pending").finish(),
MatchResult::Match { view_id, action } => f
.debug_struct("MatchResult::Match")
.field("view_id", view_id)
.field("action", &action.name())
MatchResult::None => f.debug_struct("MatchResult::None").finish(),
MatchResult::Pending => f.debug_struct("MatchResult::Pending").finish(),
MatchResult::Matches(matches) => f
.debug_list()
.entries(
matches
.iter()
.map(|(view_id, action)| format!("{view_id}, {}", action.name())),
)
.finish(),
}
}
@@ -102,13 +97,14 @@ impl PartialEq for MatchResult {
match (self, other) {
(MatchResult::None, MatchResult::None) => true,
(MatchResult::Pending, MatchResult::Pending) => true,
(
MatchResult::Match { view_id, action },
MatchResult::Match {
view_id: other_view_id,
action: other_action,
},
) => view_id == other_view_id && action.eq(other_action.as_ref()),
(MatchResult::Matches(matches), MatchResult::Matches(other_matches)) => {
matches.len() == other_matches.len()
&& matches.iter().zip(other_matches.iter()).all(
|((view_id, action), (other_view_id, other_action))| {
view_id == other_view_id && action.eq(other_action.as_ref())
},
)
}
_ => false,
}
}
@@ -119,23 +115,24 @@ impl Eq for MatchResult {}
impl Matcher {
pub fn new(keymap: Keymap) -> Self {
Self {
pending: HashMap::new(),
pending_views: HashMap::new(),
pending_keystrokes: Vec::new(),
keymap,
}
}
pub fn set_keymap(&mut self, keymap: Keymap) {
self.pending.clear();
self.clear_pending();
self.keymap = keymap;
}
pub fn add_bindings<T: IntoIterator<Item = Binding>>(&mut self, bindings: T) {
self.pending.clear();
self.clear_pending();
self.keymap.add_bindings(bindings);
}
pub fn clear_bindings(&mut self) {
self.pending.clear();
self.clear_pending();
self.keymap.clear();
}
@@ -144,11 +141,12 @@ impl Matcher {
}
pub fn clear_pending(&mut self) {
self.pending.clear();
self.pending_keystrokes.clear();
self.pending_views.clear();
}
pub fn has_pending_keystrokes(&self) -> bool {
!self.pending.is_empty()
!self.pending_keystrokes.is_empty()
}
pub fn push_keystroke(
@@ -157,53 +155,53 @@ impl Matcher {
dispatch_path: Vec<(usize, Context)>,
) -> MatchResult {
let mut any_pending = false;
let mut matched_bindings = Vec::new();
let first_keystroke = self.pending_keystrokes.is_empty();
self.pending_keystrokes.push(keystroke);
let first_keystroke = self.pending.is_empty();
for (view_id, context) in dispatch_path {
if !first_keystroke && !self.pending.contains_key(&view_id) {
// Don't require pending view entry if there are no pending keystrokes
if !first_keystroke && !self.pending_views.contains_key(&view_id) {
continue;
}
let pending = self.pending.entry(view_id).or_default();
if let Some(pending_context) = pending.context.as_ref() {
if pending_context != &context {
pending.keystrokes.clear();
// If there is a previous view context, invalidate that view if it
// has changed
if let Some(previous_view_context) = self.pending_views.remove(&view_id) {
if previous_view_context != context {
continue;
}
}
pending.keystrokes.push(keystroke.clone());
let mut retain_pending = false;
// Find the bindings which map the pending keystrokes and current context
for binding in self.keymap.bindings.iter().rev() {
if binding.keystrokes.starts_with(&pending.keystrokes)
if binding.keystrokes.starts_with(&self.pending_keystrokes)
&& binding
.context_predicate
.as_ref()
.map(|c| c.eval(&context))
.unwrap_or(true)
{
if binding.keystrokes.len() == pending.keystrokes.len() {
self.pending.remove(&view_id);
return MatchResult::Match {
view_id,
action: binding.action.boxed_clone(),
};
// If the binding is completed, push it onto the matches list
if binding.keystrokes.len() == self.pending_keystrokes.len() {
matched_bindings.push((view_id, binding.action.boxed_clone()));
} else {
retain_pending = true;
pending.context = Some(context.clone());
// Otherwise, the binding is still pending
self.pending_views.insert(view_id, context.clone());
any_pending = true;
}
}
}
if retain_pending {
any_pending = true;
} else {
self.pending.remove(&view_id);
}
}
if any_pending {
if !any_pending {
self.clear_pending();
}
if !matched_bindings.is_empty() {
MatchResult::Matches(matched_bindings)
} else if any_pending {
MatchResult::Pending
} else {
MatchResult::None
@@ -499,7 +497,7 @@ mod tests {
#[test]
fn test_push_keystroke() -> Result<()> {
actions!(test, [B, AB, C]);
actions!(test, [B, AB, C, D, DA]);
let mut ctx1 = Context::default();
ctx1.set.insert("1".into());
@@ -513,39 +511,58 @@ mod tests {
Binding::new("a b", AB, Some("1")),
Binding::new("b", B, Some("2")),
Binding::new("c", C, Some("2")),
Binding::new("d", D, Some("1")),
Binding::new("d", D, Some("2")),
Binding::new("d a", DA, Some("2")),
]);
let mut matcher = Matcher::new(keymap);
// Binding with pending prefix always takes precedence
assert_eq!(
matcher.push_keystroke(Keystroke::parse("a")?, dispatch_path.clone()),
MatchResult::Pending,
matcher.push_keystroke(Keystroke::parse("a")?, dispatch_path.clone())
);
// B alone doesn't match because a was pending, so AB is returned instead
assert_eq!(
MatchResult::Match {
view_id: 1,
action: Box::new(AB)
},
matcher.push_keystroke(Keystroke::parse("b")?, dispatch_path.clone())
matcher.push_keystroke(Keystroke::parse("b")?, dispatch_path.clone()),
MatchResult::Matches(vec![(1, Box::new(AB))]),
);
assert!(matcher.pending.is_empty());
assert!(!matcher.has_pending_keystrokes());
// Without an a prefix, B is dispatched like expected
assert_eq!(
MatchResult::Match {
view_id: 2,
action: Box::new(B)
},
matcher.push_keystroke(Keystroke::parse("b")?, dispatch_path.clone())
matcher.push_keystroke(Keystroke::parse("b")?, dispatch_path.clone()),
MatchResult::Matches(vec![(2, Box::new(B))]),
);
assert!(matcher.pending.is_empty());
assert!(!matcher.has_pending_keystrokes());
// If a is prefixed, C will not be dispatched because there
// was a pending binding for it
assert_eq!(
matcher.push_keystroke(Keystroke::parse("a")?, dispatch_path.clone()),
MatchResult::Pending,
matcher.push_keystroke(Keystroke::parse("a")?, dispatch_path.clone())
);
assert_eq!(
matcher.push_keystroke(Keystroke::parse("c")?, dispatch_path.clone()),
MatchResult::None,
matcher.push_keystroke(Keystroke::parse("c")?, dispatch_path.clone())
);
assert!(matcher.pending.is_empty());
assert!(!matcher.has_pending_keystrokes());
// If a single keystroke matches multiple bindings in the tree
// all of them are returned so that we can fallback if the action
// handler decides to propagate the action
assert_eq!(
matcher.push_keystroke(Keystroke::parse("d")?, dispatch_path.clone()),
MatchResult::Matches(vec![(2, Box::new(D)), (1, Box::new(D))]),
);
// If none of the d action handlers consume the binding, a pending
// binding may then be used
assert_eq!(
matcher.push_keystroke(Keystroke::parse("a")?, dispatch_path.clone()),
MatchResult::Matches(vec![(2, Box::new(DA))]),
);
assert!(!matcher.has_pending_keystrokes());
Ok(())
}
@@ -666,71 +683,60 @@ mod tests {
// Basic match
assert_eq!(
downcast(&matcher.test_keystroke("a", vec![(1, ctx_a.clone())])),
Some(&A("x".to_string()))
matcher.push_keystroke(Keystroke::parse("a")?, vec![(1, ctx_a.clone())]),
MatchResult::Matches(vec![(1, Box::new(A("x".to_string())))])
);
matcher.clear_pending();
// Multi-keystroke match
assert!(matcher
.test_keystroke("a", vec![(1, ctx_b.clone())])
.is_none());
assert_eq!(
downcast(&matcher.test_keystroke("b", vec![(1, ctx_b.clone())])),
Some(&Ab)
matcher.push_keystroke(Keystroke::parse("a")?, vec![(1, ctx_b.clone())]),
MatchResult::Pending
);
assert_eq!(
matcher.push_keystroke(Keystroke::parse("b")?, vec![(1, ctx_b.clone())]),
MatchResult::Matches(vec![(1, Box::new(Ab))])
);
matcher.clear_pending();
// Failed matches don't interfere with matching subsequent keys
assert!(matcher
.test_keystroke("x", vec![(1, ctx_a.clone())])
.is_none());
assert_eq!(
downcast(&matcher.test_keystroke("a", vec![(1, ctx_a.clone())])),
Some(&A("x".to_string()))
matcher.push_keystroke(Keystroke::parse("x")?, vec![(1, ctx_a.clone())]),
MatchResult::None
);
assert_eq!(
matcher.push_keystroke(Keystroke::parse("a")?, vec![(1, ctx_a.clone())]),
MatchResult::Matches(vec![(1, Box::new(A("x".to_string())))])
);
matcher.clear_pending();
// Pending keystrokes are cleared when the context changes
assert!(&matcher
.test_keystroke("a", vec![(1, ctx_b.clone())])
.is_none());
assert_eq!(
downcast(&matcher.test_keystroke("b", vec![(1, ctx_a.clone())])),
Some(&B)
matcher.push_keystroke(Keystroke::parse("a")?, vec![(1, ctx_b.clone())]),
MatchResult::Pending
);
assert_eq!(
matcher.push_keystroke(Keystroke::parse("b")?, vec![(1, ctx_a.clone())]),
MatchResult::None
);
matcher.clear_pending();
let mut ctx_c = Context::default();
ctx_c.set.insert("c".into());
// Pending keystrokes are maintained per-view
assert!(matcher
.test_keystroke("a", vec![(1, ctx_b.clone()), (2, ctx_c.clone())])
.is_none());
assert_eq!(
downcast(&matcher.test_keystroke("b", vec![(1, ctx_b.clone())])),
Some(&Ab)
matcher.push_keystroke(
Keystroke::parse("a")?,
vec![(1, ctx_b.clone()), (2, ctx_c.clone())]
),
MatchResult::Pending
);
assert_eq!(
matcher.push_keystroke(Keystroke::parse("b")?, vec![(1, ctx_b.clone())]),
MatchResult::Matches(vec![(1, Box::new(Ab))])
);
Ok(())
}
fn downcast<A: Action>(action: &Option<Box<dyn Action>>) -> Option<&A> {
action
.as_ref()
.and_then(|action| action.as_any().downcast_ref())
}
impl Matcher {
fn test_keystroke(
&mut self,
keystroke: &str,
dispatch_path: Vec<(usize, Context)>,
) -> Option<Box<dyn Action>> {
if let MatchResult::Match { action, .. } =
self.push_keystroke(Keystroke::parse(keystroke).unwrap(), dispatch_path)
{
Some(action.boxed_clone())
} else {
None
}
}
}
}

View File

@@ -3,7 +3,7 @@ authors = ["Nathan Sobo <nathansobo@gmail.com>"]
description = "The fast, collaborative code editor."
edition = "2021"
name = "zed"
version = "0.62.0"
version = "0.62.2"
[lib]
name = "zed"

View File

@@ -1 +1 @@
dev
preview

View File

@@ -1,18 +0,0 @@
#!/bin/bash
channel=$(cat crates/zed/RELEASE_CHANNEL)
tag_suffix=""
case $channel; in
stable)
;;
preview)
tag_suffix="-pre"
;;
*)
echo "do this on a release branch where RELEASE_CHANNEL is either 'preview' or 'stable'" >&2
exit 1
;;
esac
exec script/lib/bump-version.sh zed v $tag_suffix $@

View File

@@ -1,3 +1,8 @@
#!/bin/bash
exec script/lib/bump-version.sh collab collab-v '' $@
if [[ $# < 1 ]]; then
echo "Missing version increment (major, minor, or patch)" >&2
exit 1
fi
exec script/lib/bump-version.sh collab collab-v '' $1

View File

@@ -7,11 +7,11 @@ which cargo-set-version > /dev/null || cargo install cargo-edit
# Ensure we're in a clean state on an up-to-date `main` branch.
if [[ -n $(git status --short --untracked-files=no) ]]; then
echo "Can't roll the railcars with uncommitted changes"
echo "can't bump versions with uncommitted changes"
exit 1
fi
if [[ $(git rev-parse --abbrev-ref HEAD) != "main" ]]; then
echo "Run this command on the main branch"
echo "this command must be run on main"
exit 1
fi
git pull -q --ff-only origin main
@@ -28,7 +28,7 @@ next_minor=$(expr $minor + 1)
minor_branch_name="v${major}.${minor}.x"
prev_minor_branch_name="v${major}.${prev_minor}.x"
next_minor_branch_name="v${major}.${next_minor}.x"
preview_tag_name="v{major}.{minor}.{patch}-pre"
preview_tag_name="v${major}.${minor}.${patch}-pre"
function cleanup {
git checkout -q main
@@ -71,13 +71,13 @@ if git show-ref --quiet refs/tags/${stable_tag_name}; then
fi
old_prev_minor_sha=$(git rev-parse HEAD)
echo -n stable > crates/zed/RELEASE_CHANNEL
git commit -q --all --message "Stable ${prev_minor_branch_name}"
git commit -q --all --message "${prev_minor_branch_name} stable"
git tag ${stable_tag_name}
echo "Creating new preview branch ${minor_branch_name}..."
git checkout -q -b ${minor_branch_name}
echo -n preview > crates/zed/RELEASE_CHANNEL
git commit -q --all --message "Preview ${minor_branch_name}"
git commit -q --all --message "${minor_branch_name} preview"
git tag ${preview_tag_name}
echo "Preparing main for version ${next_minor_branch_name}..."
@@ -86,10 +86,10 @@ git clean -q -dff
old_main_sha=$(git rev-parse HEAD)
cargo set-version --package zed --bump minor
cargo check -q
git commit -q --all --message "Dev ${next_minor_branch_name}"
git commit -q --all --message "${next_minor_branch_name} dev"
cat <<MESSAGE
Locally rolled the railcars.
Prepared new Zed versions locally.
To push this:
git push origin \\
@@ -100,10 +100,9 @@ To push this:
main
To undo this:
git push -f . \\
git reset --hard ${old_main_sha} && git push -f . \\
:${preview_tag_name} \\
:${stable_tag_name} \\
:${minor_branch_name} \\
${old_prev_minor_sha}:${prev_minor_branch_name} \\
${old_main_sha}:main
${old_prev_minor_sha}:${prev_minor_branch_name}
MESSAGE

18
script/bump-zed-patch-version Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
channel=$(cat crates/zed/RELEASE_CHANNEL)
tag_suffix=""
case $channel in
stable)
;;
preview)
tag_suffix="-pre"
;;
*)
echo "this must be run on a stable or preview release branch" >&2
exit 1
;;
esac
exec script/lib/bump-version.sh zed v $tag_suffix patch

View File

@@ -1,14 +0,0 @@
#!/bin/bash
# Install the `plantuml` utility if it is not already installed.
if [[ -x plantuml ]]; then
brew install plantuml
fi
# Generate SVGs from all of the UML files.
plantuml \
-nometadata \
-overwrite \
-tsvg \
-o ../svg \
docs/diagrams/src/*

View File

@@ -2,18 +2,13 @@
set -eu
if [[ $# < 4 ]]; then
echo "Missing version increment (major, minor, or patch)" >&2
exit 1
fi
package=$1
tag_prefix=$2
tag_suffix=$3
version_increment=$4
if [[ -n $(git status --short --untracked-files=no) ]]; then
echo "Can't push a new version with uncommitted changes"
echo "can't bump version with uncommitted changes"
exit 1
fi
@@ -33,11 +28,10 @@ cat <<MESSAGE
Locally committed and tagged ${package} version ${new_version}
To push this:
git push origin \
${tag_name} \
git push origin \\
${tag_name} \\
${branch_name}
To undo this:
git tag -d ${tag_name} && \
git reset --hard ${old_sha}
git reset --hard ${old_sha} && git tag -d ${tag_name}
MESSAGE