src/vs/workbench/contrib/search/browser/searchView.ts/SearchView/getSearchTextFromEditor
class SearchView:	private getSearchTextFromEditor(allowUnselectedWord: boolean, editor?: IEditor): string | null {
		if (dom.isAncestor(document.activeElement, this.getContainer())) {
			return null;
		}

		editor = editor ?? this.editorService.activeTextEditorControl;
		if (isDiffEditor(editor)) {
			if (editor.getOriginalEditor().hasTextFocus()) {
				editor = editor.getOriginalEditor();
			} else {
				editor = editor.getModifiedEditor();
			}
		}

		if (!isCodeEditor(editor) || !editor.hasModel()) {
			return null;
		}

		const range = editor.getSelection();
		if (!range) {
			return null;
		}

		if (range.isEmpty() && this.searchConfig.seedWithNearestWord && allowUnselectedWord) {
			const wordAtPosition = editor.getModel().getWordAtPosition(range.getStartPosition());
			if (wordAtPosition) {
				return wordAtPosition.word;
			}
		}

		if (!range.isEmpty()) {
			let searchText = '';
			for (let i = range.startLineNumber; i <= range.endLineNumber; i++) {
				let lineText = editor.getModel().getLineContent(i);
				if (i === range.endLineNumber) {
					lineText = lineText.substring(0, range.endColumn - 1);
				}

				if (i === range.startLineNumber) {
					lineText = lineText.substring(range.startColumn - 1);
				}

				if (i !== range.startLineNumber) {
					lineText = '\n' + lineText;
				}

				searchText += lineText;
			}

			return searchText;
		}

		return null;
	}