@lvce-editor/completion-worker 1.9.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/completionWorkerMain.js +23 -19
- package/package.json +1 -1
|
@@ -1126,7 +1126,8 @@ const create = (uid, x, y, width, height, editorUid, editorLanguageId) => {
|
|
|
1126
1126
|
unfilteredItems: [],
|
|
1127
1127
|
version: 0,
|
|
1128
1128
|
editorUid,
|
|
1129
|
-
editorLanguageId
|
|
1129
|
+
editorLanguageId,
|
|
1130
|
+
maxItems: 8
|
|
1130
1131
|
};
|
|
1131
1132
|
set$1(uid, state, state);
|
|
1132
1133
|
};
|
|
@@ -1668,6 +1669,11 @@ const getListHeight = (itemsLength, itemHeight, maxHeight) => {
|
|
|
1668
1669
|
return Math.min(totalHeight, maxHeight);
|
|
1669
1670
|
};
|
|
1670
1671
|
|
|
1672
|
+
const getPositionAtCursor = async parentUid => {
|
|
1673
|
+
const position = await invoke$1('Editor.getPositionAtCursor', parentUid);
|
|
1674
|
+
return position;
|
|
1675
|
+
};
|
|
1676
|
+
|
|
1671
1677
|
const getWordAtOffset = async editorUid => {
|
|
1672
1678
|
return invoke$1('Editor.getWordAtOffset2', editorUid);
|
|
1673
1679
|
};
|
|
@@ -1677,11 +1683,13 @@ const handleEditorDeleteLeft = async state => {
|
|
|
1677
1683
|
unfilteredItems,
|
|
1678
1684
|
itemHeight,
|
|
1679
1685
|
maxHeight,
|
|
1680
|
-
editorUid
|
|
1686
|
+
editorUid,
|
|
1687
|
+
maxItems
|
|
1681
1688
|
} = state;
|
|
1682
|
-
const
|
|
1683
|
-
|
|
1684
|
-
|
|
1689
|
+
const {
|
|
1690
|
+
x,
|
|
1691
|
+
y
|
|
1692
|
+
} = await getPositionAtCursor(editorUid);
|
|
1685
1693
|
const wordAtOffset = await getWordAtOffset(editorUid);
|
|
1686
1694
|
if (!wordAtOffset) {
|
|
1687
1695
|
return {
|
|
@@ -1690,7 +1698,7 @@ const handleEditorDeleteLeft = async state => {
|
|
|
1690
1698
|
};
|
|
1691
1699
|
}
|
|
1692
1700
|
const items = filterCompletionItems(unfilteredItems, wordAtOffset);
|
|
1693
|
-
const newMaxLineY = Math.min(items.length,
|
|
1701
|
+
const newMaxLineY = Math.min(items.length, maxItems);
|
|
1694
1702
|
const height = getListHeight(items.length, itemHeight, maxHeight);
|
|
1695
1703
|
return {
|
|
1696
1704
|
...state,
|
|
@@ -1703,11 +1711,6 @@ const handleEditorDeleteLeft = async state => {
|
|
|
1703
1711
|
};
|
|
1704
1712
|
};
|
|
1705
1713
|
|
|
1706
|
-
const getPositionAtCursor = async parentUid => {
|
|
1707
|
-
const position = await invoke$1('Editor.getPositionAtCursor', parentUid);
|
|
1708
|
-
return position;
|
|
1709
|
-
};
|
|
1710
|
-
|
|
1711
1714
|
const getWordBefore = async (editorUid, rowIndex, columnIndex) => {
|
|
1712
1715
|
return invoke$1('Editor.getWordBefore2', editorUid, rowIndex, columnIndex);
|
|
1713
1716
|
};
|
|
@@ -2050,17 +2053,18 @@ const i18nString = (key, placeholders = emptyObject) => {
|
|
|
2050
2053
|
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
2051
2054
|
};
|
|
2052
2055
|
|
|
2053
|
-
const
|
|
2056
|
+
const NoSuggestions = 'No Suggestions';
|
|
2054
2057
|
|
|
2055
|
-
const
|
|
2056
|
-
return i18nString(
|
|
2058
|
+
const noSuggestions = () => {
|
|
2059
|
+
return i18nString(NoSuggestions);
|
|
2057
2060
|
};
|
|
2058
2061
|
|
|
2062
|
+
const parentNode = {
|
|
2063
|
+
type: Div,
|
|
2064
|
+
childCount: 1
|
|
2065
|
+
};
|
|
2059
2066
|
const getNoResultsVirtualDom = () => {
|
|
2060
|
-
return [
|
|
2061
|
-
type: Div,
|
|
2062
|
-
childCount: 1
|
|
2063
|
-
}, text(noResults())];
|
|
2067
|
+
return [parentNode, text(noSuggestions())];
|
|
2064
2068
|
};
|
|
2065
2069
|
|
|
2066
2070
|
const getCompletionItemsVirtualDom = visibleItems => {
|
|
@@ -2246,7 +2250,7 @@ const commandMap = {
|
|
|
2246
2250
|
'Completions.getCommandIds': getCommandIds,
|
|
2247
2251
|
'Completions.getKeyBindings': getKeyBindings,
|
|
2248
2252
|
'Completions.handleEditorDeleteLeft': wrapCommand(handleEditorDeleteLeft),
|
|
2249
|
-
'Completions.handleEditorType': handleEditorType,
|
|
2253
|
+
'Completions.handleEditorType': wrapCommand(handleEditorType),
|
|
2250
2254
|
'Completions.handleWheel': wrapCommand(handleWheel),
|
|
2251
2255
|
'Completions.initialize': initialize,
|
|
2252
2256
|
'Completions.loadContent': wrapCommand(loadContent),
|