Merge branch 'main' into markdown-fenced-blocks

Max Brunsfeld created

Change summary

crates/language/src/buffer.rs        | 23 +++++++++++
crates/zed/BundleDocumentTypes.plist | 62 +++++++++++++++++++++++++++++
script/bundle                        |  9 +++
3 files changed, 93 insertions(+), 1 deletion(-)

Detailed changes

crates/language/src/buffer.rs 🔗

@@ -806,6 +806,29 @@ impl Buffer {
         self.sync_parse_timeout = timeout;
     }
 
+    /// Called after an edit to synchronize the buffer's main parse tree with
+    /// the buffer's new underlying state.
+    ///
+    /// Locks the syntax map and interpolates the edits since the last reparse
+    /// into the foreground syntax tree.
+    ///
+    /// Then takes a stable snapshot of the syntax map before unlocking it.
+    /// The snapshot with the interpolated edits is sent to a background thread,
+    /// where we ask Tree-sitter to perform an incremental parse.
+    ///
+    /// Meanwhile, in the foreground, we block the main thread for up to 1ms
+    /// waiting on the parse to complete. As soon as it completes, we proceed
+    /// synchronously, unless a 1ms timeout elapses.
+    ///
+    /// If we time out waiting on the parse, we spawn a second task waiting
+    /// until the parse does complete and return with the interpolated tree still
+    /// in the foreground. When the background parse completes, call back into
+    /// the main thread and assign the foreground parse state.
+    ///
+    /// If the buffer or grammar changed since the start of the background parse,
+    /// initiate an additional reparse recursively. To avoid concurrent parses
+    /// for the same buffer, we only initiate a new parse if we are not already
+    /// parsing in the background.
     pub fn reparse(&mut self, cx: &mut ModelContext<Self>) {
         if self.parsing_in_background {
             return;

crates/zed/BundleDocumentTypes.plist 🔗

@@ -0,0 +1,62 @@
+<key>CFBundleDocumentTypes</key>
+<array>
+    <dict>
+        <key>CFBundleTypeIconFile</key>
+        <string>Document</string>
+        <key>CFBundleTypeRole</key>
+        <string>Editor</string>
+        <key>LSHandlerRank</key>
+        <string>Default</string>
+        <key>LSItemContentTypes</key>
+        <array>
+            <string>public.text</string>
+            <string>public.plain-text</string>
+            <string>public.utf8-plain-text</string>
+        </array>
+    </dict>
+    <dict>
+        <key>CFBundleTypeIconFile</key>
+        <string>Document</string>
+        <key>CFBundleTypeName</key>
+        <string>Zed Text Document</string>
+        <key>CFBundleTypeRole</key>
+        <string>Editor</string>
+        <key>CFBundleTypeOSTypes</key>
+        <array>
+            <string>****</string>
+        </array>
+        <key>LSHandlerRank</key>
+        <string>Default</string>
+        <key>CFBundleTypeExtensions</key>
+        <array>
+            <string>Gemfile</string>
+            <string>c</string>
+            <string>c++</string>
+            <string>cc</string>
+            <string>cpp</string>
+            <string>css</string>
+            <string>erb</string>
+            <string>ex</string>
+            <string>exs</string>
+            <string>go</string>
+            <string>h</string>
+            <string>h++</string>
+            <string>hh</string>
+            <string>hpp</string>
+            <string>html</string>
+            <string>js</string>
+            <string>json</string>
+            <string>jsx</string>
+            <string>md</string>
+            <string>py</string>
+            <string>rb</string>
+            <string>rkt</string>
+            <string>rs</string>
+            <string>scm</string>
+            <string>toml</string>
+            <string>ts</string>
+            <string>tsx</string>
+            <string>txt</string>
+        </array>
+    </dict>
+</array>

script/bundle 🔗

@@ -22,7 +22,7 @@ cargo build --release --package cli --target x86_64-apple-darwin
 
 echo "Creating application bundle"
 pushd crates/zed
-channel=$(cat RELEASE_CHANNEL)
+channel=$(<RELEASE_CHANNEL)
 cp Cargo.toml Cargo.toml.backup
 sed \
     -i .backup \
@@ -49,6 +49,13 @@ echo "Copying WebRTC.framework into the frameworks folder"
 mkdir "${app_path}/Contents/Frameworks"
 cp -R target/x86_64-apple-darwin/release/WebRTC.framework "${app_path}/Contents/Frameworks/"
 
+mv "${app_path}/Contents/Info.plist" "${app_path}/Contents/WithoutDocumentTypes.plist"
+awk \
+    "/<\/dict>/{while(getline line<\"./crates/zed/BundleDocumentTypes.plist\"){print line}}1" \
+    "${app_path}/Contents/WithoutDocumentTypes.plist" \
+    > "${app_path}/Contents/Info.plist"
+rm "${app_path}/Contents/WithoutDocumentTypes.plist"
+
 if [[ -n $MACOS_CERTIFICATE && -n $MACOS_CERTIFICATE_PASSWORD && -n $APPLE_NOTARIZATION_USERNAME && -n $APPLE_NOTARIZATION_PASSWORD ]]; then
     echo "Signing bundle with Apple-issued certificate"
     security create-keychain -p "$MACOS_CERTIFICATE_PASSWORD" zed.keychain || echo ""