Skip to content
This repository was archived by the owner on Jul 3, 2025. It is now read-only.

Only colorize visible area#20

Open
UncleBill wants to merge 4 commits intolilydjwg:masterfrom
UncleBill:master
Open

Only colorize visible area#20
UncleBill wants to merge 4 commits intolilydjwg:masterfrom
UncleBill:master

Conversation

@UncleBill
Copy link
Contributor

问题:打开或进入大文件buffer会特别卡。
解决:只处理当前的可见范围。

min() comparing to if-condition, has almost the same perfermance,(in
fact, min() is tiny faster than if-condition in most test cases), and
min() looks more clear
@UncleBill
Copy link
Contributor Author

WIP,请先别合并。

@lilydjwg
Copy link
Owner

lilydjwg commented Sep 5, 2014

嗯,期待~

@UncleBill
Copy link
Contributor Author

@lilydjwg

请问为什么要ClearMatches()

e955849 and master#L283
我刚提交的代码选择了跳过折叠,可视范围内包含折叠,移动光标也不会卡。
但打开含有颜色的折叠,已高亮的颜色就不存在了。我发现是ClearMatches()把原先的“标记”给清空了。我对colorizer的代码细节不完全清楚,所以想问问ClearMatches()的目的是什么?能否在colorizer#ColorHighlight函数中将其删掉?

UncleBill referenced this pull request Sep 5, 2014
force highlight on WinEnter and don't clear for other windows
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

比较关键的改动是这以上的十几行。

@lilydjwg
Copy link
Owner

lilydjwg commented Sep 5, 2014

那个是强制更新时用的。比如说颜色高亮出问题了,先清一遍,再重新高亮。

@lilydjwg
Copy link
Owner

lilydjwg commented Sep 5, 2014

历时太久,很多细节我也不记得了。我有空看看你的修改。

@UncleBill
Copy link
Contributor Author

历时太久,很多细节我也不记得了。我有空看看你的修改。

好的,我觉得可以将其删掉。

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个不需要了吗?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我认为不需要。因为后面还有BufEnter

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:gui 命令并不会触发 BufEnter 的呀。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:gui 命令并不会触发 BufEnter 的呀。

我并没有查到相关都文档说明这个。而且:gui还是会高亮的。

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

但是不会高亮带 alpha 值的颜色,比如 rgba(255,0,255,0.5) 这种。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗯,alpha值会被漏掉。

@lilydjwg
Copy link
Owner

lilydjwg commented Sep 7, 2014

可惜没有一个 ViewChanged 事件。

@UncleBill
Copy link
Contributor Author

可惜没有一个 ViewChanged 事件。

嗯,或者一个ScrollMoved

@UncleBill
Copy link
Contributor Author

@lilydjwg ,Hi 依云,今天浏览vim的doc,发现有个autocmdSyntax,突然想到似乎可以用在colorizer里:

diff --git a/autoload/colorizer.vim b/autoload/colorizer.vim
index 82bd3de..a974292 100644
--- a/autoload/colorizer.vim
+++ b/autoload/colorizer.vim
@@ -308,9 +308,7 @@ function! colorizer#ColorHighlight(update, ...) "{{{1
       autocmd CursorMoved,CursorMovedI * silent call s:CursorMoved()
     endif
     " rgba handles differently, so need updating
-    autocmd GUIEnter * silent call colorizer#ColorHighlight(1)
-    autocmd BufEnter * silent call colorizer#ColorHighlight(1)
-    autocmd WinEnter * silent call colorizer#ColorHighlight(1)
+    autocmd Syntax * silent call colorizer#ColorHighlight(1)
     autocmd ColorScheme * let s:force_group_update=1 | silent call colorizer#ColorHighlight(1)
   augroup END
 endfunction

至少切换window不会卡了。

@lilydjwg
Copy link
Owner

@UncleBill 这个是在 syntax 选项改变时触发的,所以 GUIEnter 是不会触发它的。BufEnter 是载入 buffer 到 window 的时候发生的,它也不会更新 syntaxWinEnter 忘记具体加它的原因了,不过在分割窗口时,新窗口会没有被高亮,就只好在进入时高亮了。这个过程中 syntax 也是没变化的。

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants