fix: others people cursors are now visible

This commit is contained in:
zaaarf 2024-09-16 23:32:46 +02:00
parent bbc2eb447a
commit b486c2c581
No known key found for this signature in database
GPG key ID: C91CFF9E2262BBA1
2 changed files with 14 additions and 14 deletions

View file

@ -36,7 +36,7 @@ public class CursorEventListener implements CaretListener {
startPos.line, startPos.column, endPos.line, endPos.column
);
new Thread(() -> { // kys
new Thread(() -> {
ApplicationManager.getApplication().runReadAction(() -> {
Editor editor = event.getEditor();
try {

View file

@ -108,7 +108,7 @@ public class InteractionUtil {
eventMulticaster.addCaretListener(new CursorEventListener()); // TODO disposable
CodeMP.getActiveWorkspace().getCursor().callback(controller -> {
ApplicationManager.getApplication().invokeLater(() -> {
new Thread(() -> {
try {
while(true) {
Optional<Cursor> c = controller.tryRecv();
@ -118,20 +118,20 @@ public class InteractionUtil {
CodeMP.LOGGER.debug(
"Cursor moved by user {}! Start pos: {}x {}y; end pos: {}x {}y in buffer {}!",
event.user,
event.startCol, event.startRow,
event.endCol, event.endRow,
event.startCol,
event.startRow,
event.endCol,
event.endRow,
event.buffer
);
try {
ApplicationManager.getApplication().invokeLater(() -> {
ApplicationManager.getApplication().runReadAction(() -> {
Editor editor = FileUtil.getActiveEditorByPath(this.myProject, event.buffer);
if(editor == null) return;
int startOffset = editor.getDocument()
.getLineStartOffset(event.startRow) + event.startCol;
int endOffset = editor.getDocument()
.getLineStartOffset(event.startRow) + event.startCol;
int startOffset = editor.getDocument().getLineStartOffset(event.startRow) + event.startCol;
int endOffset = editor.getDocument().getLineStartOffset(event.endRow) + event.endCol;
int documentLength = editor.getDocument().getTextLength();
if(startOffset > documentLength || endOffset > documentLength) {
@ -153,19 +153,19 @@ public class InteractionUtil {
null,
null,
Font.PLAIN
), HighlighterTargetArea.EXACT_RANGE
),
HighlighterTargetArea.EXACT_RANGE
)
);
if(previous != null)
previous.dispose();
if(previous != null) previous.dispose();
});
} catch(IndexOutOfBoundsException ignored) {}
} catch(IndexOutOfBoundsException ignored) {} // don't crash over a bad cursor event
}
} catch(ControllerException ex) {
notifyError(project, "Error receiving change", ex);
}
});
}).start();
});
if(after != null) after.run();