mirror of
https://github.com/hexedtech/codemp-intellij.git
synced 2024-12-22 20:44:53 +01:00
fix: others people cursors are now visible
This commit is contained in:
parent
bbc2eb447a
commit
b486c2c581
2 changed files with 14 additions and 14 deletions
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue