Skip to content

Commit 2d24dc7

Browse files
committed
Respect forceUpdate
1 parent d502e1d commit 2d24dc7

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@boatbomber/highlighter",
3-
"version": "0.5.6",
3+
"version": "0.6.0",
44
"license": "MIT",
55
"repository": {
66
"type": "git",

src/init.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ function Highlighter.highlight(props: HighlightProps)
7272
local src = SanitizeTabs(SanitizeControl(props.src or textObject.Text))
7373
local lexer = props.lexer or Highlighter.defaultLexer
7474
local customLang = props.customLang
75+
local forceUpdate = props.forceUpdate
7576

7677
-- Avoid updating when unnecessary
7778
local data = LastData[textObject]
@@ -84,7 +85,7 @@ function Highlighter.highlight(props: HighlightProps)
8485
CustomLang = customLang,
8586
}
8687
LastData[textObject] = data
87-
elseif props.forceUpdate ~= true and data.Text == src then
88+
elseif forceUpdate ~= true and data.Text == src then
8889
return
8990
end
9091

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

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

251252
-- If changed, add token to line
252-
if lines[lineNumber] ~= previousLines[lineNumber] then
253+
if forceUpdate or lines[lineNumber] ~= previousLines[lineNumber] then
253254
index += 1
254255
-- Only add RichText tags when the color is non-default and the characters are non-whitespace
255256
if Color ~= TokenColors["iden"] and string.find(line, "[%S%C]") then

wally.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "boatbomber/highlighter"
33
description = "RichText highlighting Lua code with a pure Lua lexer"
4-
version = "0.5.6"
4+
version = "0.6.0"
55
license = "MIT"
66
authors = ["boatbomber (https://boatbomber.com)"]
77
registry = "https://github.com/upliftgames/wally-index"

0 commit comments

Comments
 (0)