stop path to node from getting stale

This commit is contained in:
Kurt Hutten Irev-Dev
2025-05-12 11:52:50 +10:00
parent 2b509a515b
commit 5471c9cce9
2 changed files with 5 additions and 3 deletions

View File

@ -64,12 +64,14 @@ export class KclPlugin implements PluginValue {
editorManager.setEditorView(viewUpdate.view)
let isUserSelect = false
let didUserType = false
let isRelevant = viewUpdate.docChanged
for (const tr of viewUpdate.transactions) {
if (tr.isUserEvent('select')) {
isUserSelect = true
} else if (tr.isUserEvent('input')) {
isRelevant = true
didUserType
} else if (tr.isUserEvent('delete')) {
isRelevant = true
} else if (tr.isUserEvent('undo')) {
@ -108,7 +110,7 @@ export class KclPlugin implements PluginValue {
// If we have a user select event, we want to update what parts are
// highlighted.
if (isUserSelect) {
if (isUserSelect || didUserType) {
this._deffererUserSelect(true)
return
}

View File

@ -131,8 +131,8 @@ export function getNodeFromPath<T>(
if (
typeof stopAt !== 'undefined' &&
(isArray(stopAt)
? stopAt.includes(currentNode.type)
: currentNode.type === stopAt)
? stopAt.includes(currentNode?.type)
: currentNode?.type === stopAt)
) {
// it will match the deepest node of the type
// instead of returning at the first match