@@ -24,7 +24,6 @@ import { getRangeText, getTextBetween, type TextRange } from "../utils/textRange
2424const EMPTY_PROJECTION_STATE : SourceProjectionPluginState = {
2525 pendingCommit : null ,
2626 session : null ,
27- suppressAfterEnter : false ,
2827 suppressAt : null ,
2928} ;
3029
@@ -49,14 +48,12 @@ interface PendingProjectionCommit extends TextRange {
4948interface SourceProjectionPluginState {
5049 pendingCommit : PendingProjectionCommit | null ;
5150 session : ProjectionSession | null ;
52- suppressAfterEnter : boolean ;
5351 suppressAt : number | null ;
5452}
5553
5654type ProjectionHistoryDirection = "redo" | "undo" ;
5755
5856type ProjectionMeta =
59- | { type : "delegateEnter" }
6057 | { type : "enter" ; session : ProjectionSession }
6158 | { type : "enterFromUserEdit" ; session : ProjectionSession }
6259 | { type : "userEdit" ; previousSource : string }
@@ -202,7 +199,6 @@ export const isSourceProjectionHousekeepingTransaction = (transaction: Transacti
202199 const meta = getProjectionMeta ( transaction ) ;
203200
204201 return (
205- meta ?. type === "delegateEnter" ||
206202 meta ?. type === "enter" ||
207203 meta ?. type === "restoreBeforeCommit" ||
208204 meta ?. type === "commitAfterRestore"
@@ -253,18 +249,10 @@ const applyProjectionTransaction = (
253249) : SourceProjectionPluginState => {
254250 const meta = getProjectionMeta ( transaction ) ;
255251
256- if ( meta ?. type === "delegateEnter" ) {
257- return {
258- ...pluginState ,
259- suppressAfterEnter : true ,
260- } ;
261- }
262-
263252 if ( meta ?. type === "enter" || meta ?. type === "enterFromUserEdit" ) {
264253 return {
265254 pendingCommit : null ,
266255 session : meta . session ,
267- suppressAfterEnter : false ,
268256 suppressAt : null ,
269257 } ;
270258 }
@@ -273,7 +261,6 @@ const applyProjectionTransaction = (
273261 return {
274262 pendingCommit : meta . pendingCommit ,
275263 session : null ,
276- suppressAfterEnter : pluginState . suppressAfterEnter ,
277264 suppressAt : meta . suppressAt ,
278265 } ;
279266 }
@@ -282,22 +269,15 @@ const applyProjectionTransaction = (
282269 return {
283270 pendingCommit : null ,
284271 session : null ,
285- suppressAfterEnter : pluginState . suppressAfterEnter ,
286272 suppressAt : meta . suppressAt ,
287273 } ;
288274 }
289275
290- const didHandleDelegatedEnter = pluginState . suppressAfterEnter && transaction . docChanged ;
291- const suppressAfterEnter = didHandleDelegatedEnter ? false : pluginState . suppressAfterEnter ;
292- const suppressAt =
293- didHandleDelegatedEnter && transaction . selection . empty
294- ? transaction . selection . from
295- : getMappedSuppressPosition ( pluginState . suppressAt , transaction ) ;
276+ const suppressAt = getMappedSuppressPosition ( pluginState . suppressAt , transaction ) ;
296277
297278 if ( ! pluginState . session ) {
298279 return {
299280 ...pluginState ,
300- suppressAfterEnter,
301281 suppressAt,
302282 } ;
303283 }
@@ -317,7 +297,6 @@ const applyProjectionTransaction = (
317297 ? session . undoStack
318298 : [ ...session . undoStack , meta . previousSource ] ,
319299 } ,
320- suppressAfterEnter,
321300 suppressAt,
322301 } ;
323302 }
@@ -330,7 +309,6 @@ const applyProjectionTransaction = (
330309 redoStack : [ ...session . redoStack , meta . currentSource ] ,
331310 undoStack : session . undoStack . slice ( 0 , - 1 ) ,
332311 } ,
333- suppressAfterEnter,
334312 suppressAt,
335313 } ;
336314 }
@@ -343,7 +321,6 @@ const applyProjectionTransaction = (
343321 redoStack : session . redoStack . slice ( 0 , - 1 ) ,
344322 undoStack : [ ...session . undoStack , meta . currentSource ] ,
345323 } ,
346- suppressAfterEnter,
347324 suppressAt,
348325 } ;
349326 }
@@ -352,15 +329,13 @@ const applyProjectionTransaction = (
352329 return {
353330 pendingCommit : null ,
354331 session : null ,
355- suppressAfterEnter,
356332 suppressAt,
357333 } ;
358334 }
359335
360336 return {
361337 ...pluginState ,
362338 session,
363- suppressAfterEnter,
364339 suppressAt,
365340 } ;
366341} ;
@@ -534,11 +509,6 @@ const handleProjectionKeyDown = (view: EditorView, event: KeyboardEvent) => {
534509 }
535510
536511 if ( event . key === "Enter" ) {
537- view . dispatch (
538- view . state . tr . setMeta ( "addToHistory" , false ) . setMeta ( leafdownSourceProjectionPluginKey , {
539- type : "delegateEnter" ,
540- } satisfies ProjectionMeta ) ,
541- ) ;
542512 finalizeSourceProjection ( view ) ;
543513
544514 return false ;
0 commit comments