Skip to content

Commit

Permalink
Respect forceUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
boatbomber committed Nov 21, 2022
1 parent d502e1d commit 2d24dc7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@boatbomber/highlighter",
"version": "0.5.6",
"version": "0.6.0",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
7 changes: 4 additions & 3 deletions src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function Highlighter.highlight(props: HighlightProps)
local src = SanitizeTabs(SanitizeControl(props.src or textObject.Text))
local lexer = props.lexer or Highlighter.defaultLexer
local customLang = props.customLang
local forceUpdate = props.forceUpdate

-- Avoid updating when unnecessary
local data = LastData[textObject]
Expand All @@ -84,7 +85,7 @@ function Highlighter.highlight(props: HighlightProps)
CustomLang = customLang,
}
LastData[textObject] = data
elseif props.forceUpdate ~= true and data.Text == src then
elseif forceUpdate ~= true and data.Text == src then
return
end

Expand Down Expand Up @@ -238,7 +239,7 @@ function Highlighter.highlight(props: HighlightProps)

-- If multiline token, then set line & move to next
if l > 1 then
if lines[lineNumber] ~= previousLines[lineNumber] then
if forceUpdate or lines[lineNumber] ~= previousLines[lineNumber] then
-- Set line
lineLabels[lineNumber].Text = table.concat(richText)
end
Expand All @@ -249,7 +250,7 @@ function Highlighter.highlight(props: HighlightProps)
end

-- If changed, add token to line
if lines[lineNumber] ~= previousLines[lineNumber] then
if forceUpdate or lines[lineNumber] ~= previousLines[lineNumber] then
index += 1
-- Only add RichText tags when the color is non-default and the characters are non-whitespace
if Color ~= TokenColors["iden"] and string.find(line, "[%S%C]") then
Expand Down
2 changes: 1 addition & 1 deletion wally.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "boatbomber/highlighter"
description = "RichText highlighting Lua code with a pure Lua lexer"
version = "0.5.6"
version = "0.6.0"
license = "MIT"
authors = ["boatbomber (https://boatbomber.com)"]
registry = "https://github.com/upliftgames/wally-index"
Expand Down

0 comments on commit 2d24dc7

Please sign in to comment.