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) editorManager.setEditorView(viewUpdate.view)
let isUserSelect = false let isUserSelect = false
let didUserType = false
let isRelevant = viewUpdate.docChanged let isRelevant = viewUpdate.docChanged
for (const tr of viewUpdate.transactions) { for (const tr of viewUpdate.transactions) {
if (tr.isUserEvent('select')) { if (tr.isUserEvent('select')) {
isUserSelect = true isUserSelect = true
} else if (tr.isUserEvent('input')) { } else if (tr.isUserEvent('input')) {
isRelevant = true isRelevant = true
didUserType
} else if (tr.isUserEvent('delete')) { } else if (tr.isUserEvent('delete')) {
isRelevant = true isRelevant = true
} else if (tr.isUserEvent('undo')) { } 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 // If we have a user select event, we want to update what parts are
// highlighted. // highlighted.
if (isUserSelect) { if (isUserSelect || didUserType) {
this._deffererUserSelect(true) this._deffererUserSelect(true)
return return
} }

View File

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