mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-25 06:10:30 -04:00
26 lines
968 B
TypeScript
26 lines
968 B
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
'use strict';
|
|
|
|
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;
|
|
}
|