@lvce-editor/status-bar-worker 3.30.0 → 3.30.2

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.
@@ -1899,13 +1899,19 @@ const applyUpdate = update => {
1899
1899
  ...editorStatus,
1900
1900
  ...update
1901
1901
  };
1902
- if (typeof next.column !== 'number' || typeof next.encoding !== 'string' || typeof next.endOfLine !== 'string' || typeof next.insertSpaces !== 'boolean' || typeof next.languageId !== 'string' || typeof next.line !== 'number' || typeof next.tabSize !== 'number') {
1902
+ if (typeof next.column !== 'number' || typeof next.encoding !== 'string' || typeof next.endOfLine !== 'string' || typeof next.insertSpaces !== 'boolean' || typeof next.languageId !== 'string' || typeof next.line !== 'number' || next.selectedChars !== undefined && typeof next.selectedChars !== 'number' || typeof next.tabSize !== 'number') {
1903
1903
  throw new TypeError('The first editor status update must contain a complete status');
1904
1904
  }
1905
1905
  editorStatus = next;
1906
1906
  return editorStatus;
1907
1907
  };
1908
1908
 
1909
+ let visible = true;
1910
+ const isVisible = () => visible;
1911
+ const setVisible = value => {
1912
+ visible = value;
1913
+ };
1914
+
1909
1915
  const textItem = (name, text, ariaLabel, tooltip) => ({
1910
1916
  ariaLabel,
1911
1917
  command: '',
@@ -1927,12 +1933,15 @@ const getEditorStatusBarItems = status => {
1927
1933
  insertSpaces = true,
1928
1934
  languageId,
1929
1935
  line,
1936
+ selectedChars = 0,
1930
1937
  tabSize
1931
1938
  } = status;
1932
1939
  const encodingLabel = encoding === 'utf8' ? ['UTF', '8'].join('-') : encoding;
1933
1940
  const indentationLabel = insertSpaces ? `Spaces: ${tabSize}` : `Tab Size: ${tabSize}`;
1934
1941
  const endOfLineLabel = endOfLine.toUpperCase();
1935
- return [textItem(EditorPosition, `Ln ${line}, Col ${column}`, `Line ${line}, Column ${column}`, 'Go to Line/Column'), textItem(EditorIndentation, indentationLabel, indentationLabel, 'Select Indentation'), textItem(EditorEncoding, encodingLabel, `Encoding: ${encodingLabel}`, 'Select Encoding'), textItem(EditorEndOfLine, endOfLineLabel, `End of Line: ${endOfLineLabel}`, 'Select End of Line Sequence'), textItem(EditorLanguage, languageId, `Language: ${languageId}`, 'Select Language Mode')];
1942
+ const positionLabel = selectedChars > 0 ? `Ln ${line}, Col ${column} (${selectedChars} selected)` : `Ln ${line}, Col ${column}`;
1943
+ const positionAriaLabel = selectedChars > 0 ? `Line ${line}, Column ${column}, ${selectedChars} selected` : `Line ${line}, Column ${column}`;
1944
+ return [textItem(EditorPosition, positionLabel, positionAriaLabel, 'Go to Line/Column'), textItem(EditorIndentation, indentationLabel, indentationLabel, 'Select Indentation'), textItem(EditorEncoding, encodingLabel, `Encoding: ${encodingLabel}`, 'Select Encoding'), textItem(EditorEndOfLine, endOfLineLabel, `End of Line: ${endOfLineLabel}`, 'Select End of Line Sequence'), textItem(EditorLanguage, languageId, `Language: ${languageId}`, 'Select Language Mode')];
1936
1945
  };
1937
1946
 
1938
1947
  const dependencies = {
@@ -1940,7 +1949,7 @@ const dependencies = {
1940
1949
  [EditorEndOfLine]: ['endOfLine'],
1941
1950
  [EditorIndentation]: ['insertSpaces', 'tabSize'],
1942
1951
  [EditorLanguage]: ['languageId'],
1943
- [EditorPosition]: ['line', 'column']
1952
+ [EditorPosition]: ['line', 'column', 'selectedChars']
1944
1953
  };
1945
1954
  const handleEditorStatusChanged = (state, editorStatus, previous = state) => {
1946
1955
  const {
@@ -2075,7 +2084,48 @@ const handleEditorStatusChangedAll = async update => {
2075
2084
  newState,
2076
2085
  oldState
2077
2086
  } = get$5(uid);
2078
- const newerState = handleEditorStatusChanged(newState, editorStatus, previous);
2087
+ const newerState = isVisible() ? handleEditorStatusChanged(newState, editorStatus, previous) : {
2088
+ ...newState,
2089
+ editorStatus
2090
+ };
2091
+ if (newState === newerState || oldState === newerState) {
2092
+ continue;
2093
+ }
2094
+ set$6(uid, oldState, newerState);
2095
+ changedUids.push(uid);
2096
+ }
2097
+ await Promise.all(changedUids.map(renderOutOfBand));
2098
+ };
2099
+
2100
+ const handleEditorStatusVisibilityChanged = (state, visible) => {
2101
+ const {
2102
+ statusBarItemsRight
2103
+ } = state;
2104
+ setVisible(visible);
2105
+ if (!visible) {
2106
+ const editorItems = statusBarItemsRight.filter(item => isEditorStatus(item.name));
2107
+ if (editorItems.length === 0) {
2108
+ return state;
2109
+ }
2110
+ return {
2111
+ ...state,
2112
+ statusBarItemsRight: statusBarItemsRight.filter(item => !isEditorStatus(item.name))
2113
+ };
2114
+ }
2115
+ return handleEditorStatusChanged(state, get$2(), {
2116
+ editorStatus: undefined
2117
+ });
2118
+ };
2119
+
2120
+ const handleEditorStatusVisibilityChangedAll = async visible => {
2121
+ setVisible(visible);
2122
+ const changedUids = [];
2123
+ for (const uid of getKeys()) {
2124
+ const {
2125
+ newState,
2126
+ oldState
2127
+ } = get$5(uid);
2128
+ const newerState = handleEditorStatusVisibilityChanged(newState, visible);
2079
2129
  if (newState === newerState || oldState === newerState) {
2080
2130
  continue;
2081
2131
  }
@@ -2381,6 +2431,7 @@ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess =
2381
2431
  const rpc = await create$2({
2382
2432
  commandMap: {
2383
2433
  'StatusBar.handleEditorStatusChanged': handleEditorStatusChangedAll,
2434
+ 'StatusBar.handleEditorStatusVisibilityChanged': handleEditorStatusVisibilityChangedAll,
2384
2435
  'StatusBar.supportsEditorStatusDeltas': supportsEditorStatusDeltas,
2385
2436
  'Viewlet.executeViewletCommand': executeViewletCommand
2386
2437
  },
@@ -2517,7 +2568,14 @@ const loadContent = async state => {
2517
2568
  statusBarItemsRight: statusBarItems.filter(item => isRight(item.name)),
2518
2569
  warningCount: 0
2519
2570
  };
2520
- const currentState = itemsVisible ? handleEditorStatusChanged(loadedState, get$2()) : loadedState;
2571
+ let currentState = loadedState;
2572
+ if (itemsVisible) {
2573
+ if (isVisible()) {
2574
+ currentState = handleEditorStatusChanged(loadedState, get$2());
2575
+ } else {
2576
+ currentState = handleEditorStatusVisibilityChanged(loadedState, false);
2577
+ }
2578
+ }
2521
2579
  const latestNotificationCount = get$1();
2522
2580
  if (latestNotificationCount === undefined) {
2523
2581
  return currentState;
@@ -2607,6 +2665,7 @@ const commandMap = {
2607
2665
  'StatusBar.handleClick': wrapCommand(handleClick),
2608
2666
  'StatusBar.handleContextMenu': wrapCommand(handleContextMenu),
2609
2667
  'StatusBar.handleEditorStatusChanged': handleEditorStatusChangedAll,
2668
+ 'StatusBar.handleEditorStatusVisibilityChanged': handleEditorStatusVisibilityChangedAll,
2610
2669
  'StatusBar.handleExtensionManagementMessagePort': handleExtensionManagementMessagePort,
2611
2670
  'StatusBar.handleExtensionsChanged': refreshExtensionItems,
2612
2671
  'StatusBar.handleItemsChanged': refreshExtensionItems,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/status-bar-worker",
3
- "version": "3.30.0",
3
+ "version": "3.30.2",
4
4
  "description": "Status Bar Worker",
5
5
  "repository": {
6
6
  "type": "git",