Skip to content

GLSP-1827: Fix own save triggering the source model changed dialog - #306

Merged
tortmayr merged 2 commits into
masterfrom
fix-file-watcher-own-save
Nov 17, 2026
Merged

tortmayr merged 2 commits into
masterfrom
fix-file-watcher-own-save

Conversation

@tortmayr

@tortmayr tortmayr commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

What it does

The WatchService delivers events asynchronously, so the event of a save can arrive after SaveModelActionHandler resumed the FileWatcher and pass the paused check. The client then shows the "Source of editor changed" dialog for the server's own write.

  • Record the file's modification time and size on resume and drop events while the file still matches. A resume delay would depend on the platform's event latency (the macOS WatchService polls every 10 s by default) and miss every external edit within it
  • Add a test that pauses, writes and resumes without waiting, the way SaveModelActionHandler does

Fixes eclipse-glsp/glsp#1827

How to test

mvn clean verify -Pm2 -B
  • The new FileWatcherTest case fails without the fix (1 notification instead of 0) and passes with it, verified locally
  • m2 + fatjar and p2 builds pass, checkstyle clean

Manual: open a .wf diagram in the Theia integration, edit and save repeatedly. The "Source of editor changed" dialog no longer appears. Editing the file in a text editor still shows it.:

  • start the server with java -jar examples/org.eclipse.glsp.example.workflow/target/org.eclipse.glsp.example.workflow-2.9.0-SNAPSHOT-glsp.jar -p 5007
  • start the theia application with pnpm run browser start:debug

Follow-ups

Changelog

  • This PR should be mentioned in the changelog
  • This PR introduces a breaking change (if yes, provide more details below for the changelog and the migration guide)

The WatchService delivers events asynchronously, so the event of a save
can arrive after the watcher resumed and pass the paused check.

- Record the file's modification time and size on resume and drop
  events while the file still matches. A resume delay would depend on
  the platform's event latency and miss every external edit within it
- Add a test that pauses, writes and resumes without waiting, the way
  SaveModelActionHandler does

Fixes eclipse-glsp/glsp#1827
@tortmayr
tortmayr force-pushed the fix-file-watcher-own-save branch from 2d11d48 to 6d98379 Compare November 17, 2026 14:21
- Rename hasChanged() to updateKnownState(), since it also records the
  state and a second call for the same event returns false
- Document that the comparison depends on the file system's timestamp
  resolution
@tortmayr
tortmayr requested a review from fismif November 17, 2026 15:58

@fismif fismif left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! I verified the bug fix myself and also the waytcher tests pass reliably.

@tortmayr
tortmayr merged commit 685cc02 into master Nov 17, 2026
7 checks passed
@tortmayr
tortmayr deleted the fix-file-watcher-own-save branch November 17, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Java Server] Saving the diagram triggers the "Source of editor changed" dialog

2 participants