diff --git a/src/text/text_editor.nim b/src/text/text_editor.nim index 5800a609..3120d99b 100644 --- a/src/text/text_editor.nim +++ b/src/text/text_editor.nim @@ -244,8 +244,8 @@ method getEventHandlers*(self: TextDocumentEditor, inject: Table[string, EventHa result.add inject["above-completion"] proc preRender*(self: TextDocumentEditor) = + self.clearCustomHighlights(errorNodesHighlightId) if self.configProvider.getValue("editor.text.highlight-treesitter-errors", true): - self.clearCustomHighlights(errorNodesHighlightId) let errorNodes = self.document.getErrorNodesInRange(self.visibleTextRange(buffer = 10)) for node in errorNodes: self.addCustomHighlight(errorNodesHighlightId, node, "editorError.foreground", color(1, 1, 1, 0.3)) diff --git a/src/ui/widget_builder_text_document.nim b/src/ui/widget_builder_text_document.nim index b984a6de..a280b517 100644 --- a/src/ui/widget_builder_text_document.nim +++ b/src/ui/widget_builder_text_document.nim @@ -65,7 +65,10 @@ proc renderLine*( flagsInner.incl SizeToContentX let hasDiagnostic = self.diagnosticsPerLine.contains(lineNumber) - let diagnosticIndices = if hasDiagnostic: self.diagnosticsPerLine[lineNumber] else: @[] + let diagnosticIndices = if hasDiagnostic: + self.diagnosticsPerLine[lineNumber] + else: + @[] var diagnosticColorName = "editorHint.foreground" var diagnosticMessage: string = "■ " if hasDiagnostic: @@ -99,7 +102,7 @@ proc renderLine*( lineNumberText = $lineNumber lineNumberX = max(0.0, lineNumberWidth - lineNumberText.len.float * builder.charWidth) elif lineNumbers == LineNumbers.Relative: - lineNumberText = $(lineNumber - cursorLine).abs + lineNumberText = $abs(lineNumber - cursorLine) lineNumberX = max(0.0, lineNumberWidth - lineNumberText.len.float * builder.charWidth) builder.panel(flagsInner + LayoutVertical, y = y, pivot = pivot, userId = newSecondaryId(parentId, lineId)): @@ -351,7 +354,7 @@ proc renderLine*( if hasDiagnostic and partIndex >= line.parts.len: let diagnosticXOffset = 7 * builder.charWidth - for _ in 0..0: + for i in 0..0: insertDiagnostic = false if diagnosticXOffset + diagnosticMessageWidth > lineWidth - lastPartXW: if subLinePartIndex > 0: