@@ -15,7 +15,7 @@ use crate::{
1515
1616use codemp_proto:: {
1717 common:: Empty ,
18- files:: { BufferNode , BufferPath } ,
18+ files:: { BufferAttributes , BufferNode , BufferPath } ,
1919 workspace:: { WorkspaceEvent , WorkspaceEventKind } ,
2020} ;
2121
@@ -48,7 +48,7 @@ pub(crate) struct WorkspaceInner {
4848 cursor : cursor:: Controller ,
4949 buffers : DashMap < String , buffer:: Controller > ,
5050 services : Services ,
51- filetree : DashMap < String , crate :: proto :: files :: BufferNode > ,
51+ filetree : DashMap < String , BufferNode > ,
5252 buffer_users : DashMap < String , Vec < String > > ,
5353 users : Arc < DashMap < String , codemp_proto:: common:: UserInfo > > ,
5454 events : tokio:: sync:: Mutex < mpsc:: UnboundedReceiver < WorkspaceEvent > > ,
@@ -158,22 +158,23 @@ impl Workspace {
158158 }
159159
160160 /// Create a new buffer in the current workspace.
161- pub async fn create_buffer ( & self , path : impl ToString , ephemeral : bool ) -> RemoteResult < ( ) > {
161+ pub async fn create_buffer ( & self , path : impl ToString , attributes : Option < BufferAttributes > ) -> RemoteResult < ( ) > {
162162 let mut workspace_client = self . 0 . services . ws ( ) ;
163163 let path = path. to_string ( ) ;
164+ let attributes = attributes. unwrap_or_default ( ) ;
164165 workspace_client
165166 . create_buffer ( tonic:: Request :: new ( BufferNode {
166- path : crate :: proto :: files :: BufferPath :: from ( & path) ,
167- ephemeral ,
167+ path : BufferPath :: from ( & path) ,
168+ attributes ,
168169 } ) )
169170 . await ?;
170171
171172 // add to filetree, not really necessary as we will get an event for it
172173 self . 0 . filetree . insert (
173174 path. clone ( ) ,
174- crate :: proto :: files :: BufferNode {
175- path : crate :: proto :: files :: BufferPath :: from ( & path) ,
176- ephemeral ,
175+ BufferNode {
176+ path : BufferPath :: from ( & path) ,
177+ attributes ,
177178 } ,
178179 ) ;
179180
@@ -467,11 +468,11 @@ impl WorkspaceWorker {
467468 } ,
468469
469470 WorkspaceEventKind :: FileCreate => {
470- if let ( Some ( path) , Some ( ephemeral ) ) = ( event. path, event. ephemeral ) {
471+ if let ( Some ( path) , Some ( attributes ) ) = ( event. path, event. attributes ) {
471472 inner. buffer_users. insert( path. clone( ) , Vec :: new( ) ) ;
472- inner. filetree. insert( path. clone( ) , crate :: proto :: files :: BufferNode {
473- path: crate :: proto :: files :: BufferPath :: from( & path) ,
474- ephemeral
473+ inner. filetree. insert( path. clone( ) , BufferNode {
474+ path: BufferPath :: from( & path) ,
475+ attributes
475476 } ) ;
476477 }
477478 }
@@ -495,6 +496,14 @@ impl WorkspaceWorker {
495496 let _ = inner. buffers. remove( & path) ;
496497 }
497498 }
499+ WorkspaceEventKind :: FileAttrsUpdated => {
500+ if let ( Some ( path) , Some ( attributes) ) = ( event. path, event. attributes) {
501+ if let Some ( mut r) = inner. filetree. get_mut( & path) {
502+ r. attributes = attributes;
503+ }
504+ }
505+ }
506+
498507 }
499508
500509 if self . events. send( _event) . is_err( ) {
0 commit comments