Browse Source

fix variable spelling, improve async functions

Andrew Schlaepfer 6 years ago
parent
commit
f33db4b8bf

+ 5 - 5
packages/csvviewer-extension/src/searchprovider.ts

@@ -72,7 +72,7 @@ export class CSVSearchProvider implements ISearchProvider {
    *
    * @returns A promise that resolves once the action has completed.
    */
-  highlightPrevious(): Promise<ISearchMatch | undefined> {
+  async highlightPrevious(): Promise<ISearchMatch | undefined> {
     this._target.content.searchService.find(this._query, true);
     return undefined;
   }
@@ -82,8 +82,8 @@ export class CSVSearchProvider implements ISearchProvider {
    * Not implemented in the CSV viewer as it is read-only.
    * @returns A promise that resolves once the action has completed.
    */
-  replaceCurrentMatch(newText: string): Promise<boolean> {
-    return Promise.resolve(false);
+  async replaceCurrentMatch(newText: string): Promise<boolean> {
+    return false;
   }
 
   /**
@@ -91,8 +91,8 @@ export class CSVSearchProvider implements ISearchProvider {
    * Not implemented in the CSV viewer as it is read-only.
    * @returns A promise that resolves once the action has completed.
    */
-  replaceAllMatches(newText: string): Promise<boolean> {
-    return Promise.resolve(false);
+  async replaceAllMatches(newText: string): Promise<boolean> {
+    return false;
   }
 
   /**

+ 2 - 2
packages/documentsearch/src/interfaces.ts

@@ -45,9 +45,9 @@ export interface IDisplayState {
    */
   forceFocus: boolean;
 
-  searchInputFocussed: boolean;
+  searchInputFocused: boolean;
 
-  replaceInputFocussed: boolean;
+  replaceInputFocused: boolean;
 
   replaceText: string;
 

+ 3 - 3
packages/documentsearch/src/providers/notebooksearchprovider.ts

@@ -191,12 +191,12 @@ export class NotebookSearchProvider implements ISearchProvider {
       if (replaceOccurred) {
         this._currentMatch = provider.currentMatch;
         if (this._currentMatch) {
-          return Promise.resolve(replaceOccurred);
+          return replaceOccurred;
         }
       }
     }
     await this.highlightNext();
-    return Promise.resolve(replaceOccurred);
+    return replaceOccurred;
   }
 
   async replaceAllMatches(newText: string): Promise<boolean> {
@@ -207,7 +207,7 @@ export class NotebookSearchProvider implements ISearchProvider {
       replaceOccurred = singleReplaceOccurred ? true : replaceOccurred;
     }
     this._currentMatch = null;
-    return Promise.resolve(replaceOccurred);
+    return replaceOccurred;
   }
 
   /**

+ 2 - 2
packages/documentsearch/src/searchinstance.ts

@@ -199,8 +199,8 @@ export class SearchInstance implements IDisposable {
     inputText: '',
     query: null,
     errorMessage: '',
-    searchInputFocussed: true,
-    replaceInputFocussed: false,
+    searchInputFocused: true,
+    replaceInputFocused: false,
     forceFocus: true,
     replaceText: '',
     replaceEntryShown: false

+ 9 - 9
packages/documentsearch/src/searchoverlay.tsx

@@ -32,7 +32,7 @@ const REPLACE_BUTTON_WRAPPER_CLASS = 'jp-DocumentSearch-replace-button-wrapper';
 const REPLACE_WRAPPER_CLASS = 'jp-DocumentSearch-replace-wrapper-class';
 const REPLACE_TOGGLE_COLLAPSED = 'jp-DocumentSearch-replace-toggle-collapsed';
 const REPLACE_TOGGLE_EXPANDED = 'jp-DocumentSearch-replace-toggle-expanded';
-const FOCUSSED_INPUT = 'jp-DocumentSearch-focussed-input';
+const FOCUSED_INPUT = 'jp-DocumentSearch-focused-input';
 const TOGGLE_WRAPPER = 'jp-DocumentSearch-toggle-wrapper';
 const TOGGLE_PLACEHOLDER = 'jp-DocumentSearch-toggle-placeholder';
 const BUTTON_CONTENT_CLASS = 'jp-DocumentSearch-button-content';
@@ -45,7 +45,7 @@ interface ISearchEntryProps {
   onChange: Function;
   onInputFocus: Function;
   onInputBlur: Function;
-  inputFocussed: boolean;
+  inputFocused: boolean;
   caseSensitive: boolean;
   useRegex: boolean;
   inputText: string;
@@ -73,7 +73,7 @@ class SearchEntry extends React.Component<ISearchEntryProps> {
   }
 
   componentDidUpdate() {
-    if (this.props.forceFocus && this.props.inputFocussed) {
+    if (this.props.forceFocus && this.props.inputFocused) {
       this.focusInput();
     }
   }
@@ -87,7 +87,7 @@ class SearchEntry extends React.Component<ISearchEntryProps> {
       : REGEX_BUTTON_CLASS_OFF;
 
     const wrapperClass = `${INPUT_WRAPPER_CLASS} ${
-      this.props.inputFocussed ? FOCUSSED_INPUT : ''
+      this.props.inputFocused ? FOCUSED_INPUT : ''
     }`;
 
     return (
@@ -331,14 +331,14 @@ class SearchOverlay extends React.Component<
   }
 
   private _onSearchInputFocus() {
-    if (!this.state.searchInputFocussed) {
-      this.setState({ searchInputFocussed: true });
+    if (!this.state.searchInputFocused) {
+      this.setState({ searchInputFocused: true });
     }
   }
 
   private _onSearchInputBlur() {
-    if (this.state.searchInputFocussed) {
-      this.setState({ searchInputFocussed: false });
+    if (this.state.searchInputFocused) {
+      this.setState({ searchInputFocused: false });
     }
   }
 
@@ -378,7 +378,7 @@ class SearchOverlay extends React.Component<
           onChange={(e: React.ChangeEvent) => this._onSearchChange(e)}
           onInputFocus={this._onSearchInputFocus.bind(this)}
           onInputBlur={this._onSearchInputBlur.bind(this)}
-          inputFocussed={this.state.searchInputFocussed}
+          inputFocused={this.state.searchInputFocused}
           inputText={this.state.inputText}
           forceFocus={this.props.overlayState.forceFocus}
         />

+ 1 - 1
packages/documentsearch/style/index.css

@@ -53,7 +53,7 @@
   margin: 2px;
 }
 
-.jp-DocumentSearch-focussed-input {
+.jp-DocumentSearch-focused-input {
   border: var(--jp-border-width) solid var(--jp-cell-editor-active-border-color);
 }