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 startPos.line, startPos.column, endPos.line, endPos.column
); );
new Thread(() -> { // kys new Thread(() -> {
ApplicationManager.getApplication().runReadAction(() -> { ApplicationManager.getApplication().runReadAction(() -> {
Editor editor = event.getEditor(); Editor editor = event.getEditor();
try { try {

View file

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