mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-25 09:06:21 +01:00
Moving code incorporating feedback.
This commit is contained in:
@@ -2082,24 +2082,3 @@ export var Handler = {
|
||||
Undo: 'undo',
|
||||
Redo: 'redo',
|
||||
};
|
||||
|
||||
/**
|
||||
*@internal
|
||||
*/
|
||||
export function getSelectionSearchString(editor: ICommonCodeEditor): string {
|
||||
let selection = editor.getSelection();
|
||||
|
||||
// if selection spans multiple lines, default search string to empty
|
||||
if (selection.startLineNumber === selection.endLineNumber) {
|
||||
if (selection.isEmpty()) {
|
||||
let wordAtPosition = editor.getModel().getWordAtPosition(selection.getStartPosition());
|
||||
if (wordAtPosition) {
|
||||
return wordAtPosition.word;
|
||||
}
|
||||
} else {
|
||||
return editor.getModel().getValueInRange(selection);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
|
||||
export function getSelectionSearchString(editor: editorCommon.ICommonCodeEditor): string {
|
||||
let selection = editor.getSelection();
|
||||
|
||||
// if selection spans multiple lines, default search string to empty
|
||||
if (selection.startLineNumber === selection.endLineNumber) {
|
||||
if (selection.isEmpty()) {
|
||||
let wordAtPosition = editor.getModel().getWordAtPosition(selection.getStartPosition());
|
||||
if (wordAtPosition) {
|
||||
return wordAtPosition.word;
|
||||
}
|
||||
} else {
|
||||
return editor.getModel().getValueInRange(selection);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { editorAction, commonEditorContribution, ServicesAccessor, EditorAction, EditorCommand, CommonEditorRegistry } from 'vs/editor/common/editorCommonExtensions';
|
||||
import { FIND_IDS, FindModelBoundToEditorModel, ToggleCaseSensitiveKeybinding, ToggleRegexKeybinding, ToggleWholeWordKeybinding, ToggleSearchScopeKeybinding, ShowPreviousFindTermKeybinding, ShowNextFindTermKeybinding } from 'vs/editor/contrib/find/common/findModel';
|
||||
import { FindReplaceState, FindReplaceStateChangedEvent, INewFindReplaceState } from 'vs/editor/contrib/find/common/findState';
|
||||
import { getSelectionSearchString } from 'vs/editor/contrib/find/common/find';
|
||||
import { DocumentHighlightProviderRegistry } from 'vs/editor/common/modes';
|
||||
import { RunOnceScheduler, Delayer } from 'vs/base/common/async';
|
||||
import { CursorChangeReason, ICursorSelectionChangedEvent } from 'vs/editor/common/controller/cursorEvents';
|
||||
@@ -206,7 +207,7 @@ export class CommonFindController extends Disposable implements editorCommon.IEd
|
||||
}
|
||||
|
||||
public getSelectionSearchString(): string {
|
||||
return editorCommon.getSelectionSearchString(this._editor);
|
||||
return getSelectionSearchString(this._editor);
|
||||
}
|
||||
|
||||
protected _start(opts: IFindStartOptions): void {
|
||||
|
||||
@@ -24,7 +24,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
|
||||
import { ICodeEditorService } from 'vs/editor/common/services/codeEditorService';
|
||||
import { getSelectionSearchString } from 'vs/editor/common/editorCommon';
|
||||
import { getSelectionSearchString } from 'vs/editor/contrib/find/common/find';
|
||||
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
||||
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { ITree } from 'vs/base/parts/tree/browser/tree';
|
||||
|
||||
Reference in New Issue
Block a user