Skip to content

Commit

Permalink
fixed syntax error highlight toggling
Browse files Browse the repository at this point in the history
  • Loading branch information
Nimaoth committed Mar 16, 2024
1 parent 8c26ee6 commit 530ac5a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/text/text_editor.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
9 changes: 6 additions & 3 deletions src/ui/widget_builder_text_document.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)):
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 530ac5a

Please sign in to comment.