From 9e8eba93ccebe4e16e8df01b5a8b4c2b1ff4c575 Mon Sep 17 00:00:00 2001
From: SeeBasTStick <sebastian.stock@hhu.de>
Date: Mon, 22 Jun 2020 20:02:22 +0200
Subject: [PATCH] bug fix regarding wrongly shown bug

---
 CHANGELOG.md         |  8 +++++++-
 README.md            |  7 ++++++-
 server/src/server.ts | 33 +++++++++++++++++++++++++--------
 3 files changed, 38 insertions(+), 10 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index e5ba892..1f73062 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -71,4 +71,10 @@
 
 ## [0.6.3]
 
-- fixed recognition of failing probcli
\ No newline at end of file
+- fixed recognition of failing probcli
+
+
+
+## [0.6.4]
+
+- fixed bug where sometimes changes lead to wrong represantation of mistakes
\ No newline at end of file
diff --git a/README.md b/README.md
index 85717d7..1122143 100644
--- a/README.md
+++ b/README.md
@@ -104,4 +104,9 @@ Please note that user settings overwrite workspace settings.
 
 ### 0.6.3
 
-- fixed recognition of failing probcli
\ No newline at end of file
+- fixed recognition of failing probcli
+
+
+### 0.6.4
+
+- fixed bug where sometimes changes lead to wrong represantation of mistakes
\ No newline at end of file
diff --git a/server/src/server.ts b/server/src/server.ts
index b6d4acc..47c2b0f 100644
--- a/server/src/server.ts
+++ b/server/src/server.ts
@@ -160,6 +160,13 @@ documents.onDidSave(change => {
 	validateTextDocument(change.document)
 })
 
+documents.onDidChangeContent(change => {
+//	validateTextDocument(change.document);
+});
+
+
+
+
 
 async function validateTextDocument(textDocument: TextDocument): Promise<void> {
 	let settings = await getDocumentSettings(textDocument.uri) // Waiting for correct setting; otherwise allways default
@@ -176,8 +183,9 @@ async function validateTextDocument(textDocument: TextDocument): Promise<void> {
 		fs.mkdirSync(errorDic);
 	}
 
-	fs.writeFile(errorPath, "", () => { }) //Insure a clean error file
 
+	fs.writeFile(errorPath, "", () => { }) //Insure a clean error file
+	//fs.writeFileSync(errorPath,"",{encoding:'utf8',flag:'w'})
 	let command: string = getCommand(URI.parse(textDocument.uri).path, errorPath, settings)
 //	console.log(command)
 	if (correctPath(settings.probHome)) {
@@ -186,14 +194,19 @@ async function validateTextDocument(textDocument: TextDocument): Promise<void> {
 			errorMap.then(function (result: Map<string, Set<NDJSON>>) {
 
 				let diagnostics: Array<Diagnostic> = new Array()
-
-				for (let entry of result) {
-					if (entry[0] == textDocument.uri) {
-						diagnostics = matchErrors(entry[1], textDocument)
-					} else {
-						diagnostics = matchErrors(entry[1])
+				if(result.size != 0)
+				{
+					for (let entry of result) {
+						if (entry[0] == textDocument.uri) {
+							diagnostics = matchErrors(entry[1], textDocument)
+						} else {
+							diagnostics = matchErrors(entry[1])
+						}
+						connection.sendDiagnostics({ uri: entry[0], diagnostics });
 					}
-					connection.sendDiagnostics({ uri: entry[0], diagnostics });
+				}
+				else{
+					connection.sendDiagnostics({ uri: textDocument.uri, diagnostics });
 				}
 
 			}, function (err) {
@@ -210,6 +223,9 @@ async function validateTextDocument(textDocument: TextDocument): Promise<void> {
 		
 		})
 	}
+
+	fs.writeFile(errorPath, "", () => { }) //Insure a clean error file
+
 }
 
 
@@ -271,6 +287,7 @@ connection.onCompletion(
 
 
 
+
 //Can be used to enrich completion with more infos
 connection.onCompletionResolve(
 	(item: CompletionItem) => { return item })
-- 
GitLab