Commit aaed6c9f authored by Johannes Roith's avatar Johannes Roith

fix the column bug.

parent e983a3c5
......@@ -35,9 +35,7 @@ class CTEDocumentListener implements IDocumentListener {
return;
}
private void patchModel(DocumentEvent event) {
// long timerBefore = System.currentTimeMillis(); // TODO: remove!
private void patchModel(DocumentEvent event) {
IDocument document = event.getDocument();
Model model = Model.getInstanceForDocument(document);
......@@ -48,7 +46,9 @@ class CTEDocumentListener implements IDocumentListener {
return;
int offset = event.getOffset();
int textLength = event.getText().length();
int removedLength = event.getLength();
int offsetOfLineTwo = -1;
int linesAdded = 0;
int addedLastLineColumns = 0;
......@@ -61,13 +61,13 @@ class CTEDocumentListener implements IDocumentListener {
e.printStackTrace();
}
int endOffset = offset + event.getText().length();
int endOffset = offset + textLength;
int endLineNumber = document.getLineOfOffset(endOffset);
addedLastLineColumns = endOffset
- document.getLineOffset(endLineNumber);
linesAdded = endLineNumber - startLineNumber;
/* System.out.println("PROCESSING DocumentEvent: ");
/*
System.out.println("PROCESSING DocumentEvent: ");
System.out.println(" Offset: " + offset);
System.out.println(" Replaced: " + event.getLength());
System.out.println(" New: " + event.getText().length());
......@@ -81,27 +81,22 @@ class CTEDocumentListener implements IDocumentListener {
// NOTE: we do not try to fix the replaced part.
int fixColumnUntilOffset = offsetOfLineTwo;
int fixAfterOffset = offset + event.getLength();
int diffOffset = event.getText().length() - event.getLength();
int fixColumnUntilOffset = offsetOfLineTwo + removedLength;
int fixAfterOffset = offset + removedLength;
int diffOffset = textLength - removedLength;
int diffLines = linesAdded - linesRemoved;
int diffColumns = addedLastLineColumns - removedLastLineColumns;
/* System.out.println(" fixAfterOffset: " + fixAfterOffset);
/*
System.out.println(" fixAfterOffset: " + fixAfterOffset);
System.out.println(" offsetOfLineTwo: " + offsetOfLineTwo);
System.out.println(" diffOffset: " + diffOffset);
System.out.println(" diffLines: " + diffLines);
System.out.println(" diffColumns: " + diffColumns);
*/
System.out.println(" fixAfterOffset: " + fixAfterOffset);
System.out.println(" offsetOfLineTwo: " + offsetOfLineTwo);
LocationPatchVisitor visitor = new LocationPatchVisitor(fixAfterOffset,
fixColumnUntilOffset, diffLines, diffColumns, diffOffset);
ast.accept(visitor, null);
// long timerAfter = System.currentTimeMillis(); // TODO: remove!
// System.out.println("Location patch took: " + (timerAfter - timerBefore) + " millis.");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment