Repository: microsoft/vscode
File: src/vs/editor/browser/view/viewController.ts (TypeScript)

Code before:
			case 'ctrlKey':
				return data.ctrlKey;
			case 'metaKey':
				return data.metaKey;
			default:
				return false;
		}
	}

	private _hasNonMulticursorModifier(data: IMouseDispatchData): boolean {
		switch (this.configuration.options.get(EditorOption.multiCursorModifier)) {
			case 'altKey':
				return data.ctrlKey || data.metaKey;
			case 'ctrlKey':
				return data.altKey || data.metaKey;
			case 'metaKey':
				return data.ctrlKey || data.altKey;
			default:
				return false;
		}
	}

	/**
	 * Selects content inside brackets if the position is right after an opening bracket or right before a closing bracket.
	 */
	private _trySelectBracketContent(viewPosition: Position): Selection | undefined {
		const pos = this._convertViewToModelPosition(viewPosition);
		const model = this.viewModel.model;

		// Try to find bracket match if we're right after an opening bracket.
		if (pos.column > 1) {
			const pair = model.bracketPairs.matchBracket(pos.with(undefined, pos.column - 1));
			if (pair && pair[0].getEndPosition().equals(pos)) {
				return Selection.fromPositions(pair[0].getEndPosition(), pair[1].getStartPosition());
			}
		}

		// Try to find bracket match if we're right before a closing bracket.
		if (pos.column <= model.getLineMaxColumn(pos.lineNumber)) {
			const pair = model.bracketPairs.matchBracket(pos);
			if (pair && pair[1].getStartPosition().equals(pos)) {
				return Selection.fromPositions(pair[0].getEndPosition(), pair[1].getStartPosition());
			}
		}

		return undefined;
	}

	/**
	 * Selects content inside a string if the position is right after an opening quote or right before a closing quote.
	 */

Review comment (bug):
Since these methods dont really depend on the view model, but mostly on the model, I'd decompose that step:
```
// Should return selection in view model to be consistent
private _trySelectBracketContentInViewModel(viewPosition: Position): Selection | undefined {
```
which calls
```
function _trySelectBracketContent(position: Position, model: ITextModel): Selection | undefined {
```

...when not being very clear about if a position is a view or model position, subtle bugs will occur (that usually only show when word wrapping or folding is used).

Code after:
				return data.altKey;
			case 'ctrlKey':
				return data.ctrlKey;
			case 'metaKey':
				return data.metaKey;
			default:
				return false;
		}
	}

	private _hasNonMulticursorModifier(data: IMouseDispatchData): boolean {
		switch (this.configuration.options.get(EditorOption.multiCursorModifier)) {
			case 'altKey':
				return data.ctrlKey || data.metaKey;
			case 'ctrlKey':
				return data.altKey || data.metaKey;
			case 'metaKey':
				return data.ctrlKey || data.altKey;
			default:
				return false;
		}
	}

	/**
	 * Selects content inside brackets if the position is right after an opening bracket or right before a closing bracket.
	 * @param pos The position in the model.
	 * @param model The text model.
	 */
	private static _trySelectBracketContent(model: ITextModel, pos: Position): Selection | undefined {
		// Try to find bracket match if we're right after an opening bracket.
		if (pos.column > 1) {
			const pair = model.bracketPairs.matchBracket(pos.with(undefined, pos.column - 1));
			if (pair && pair[0].getEndPosition().equals(pos)) {
				return Selection.fromPositions(pair[0].getEndPosition(), pair[1].getStartPosition());
			}
		}

		// Try to find bracket match if we're right before a closing bracket.
		if (pos.column <= model.getLineMaxColumn(pos.lineNumber)) {
			const pair = model.bracketPairs.matchBracket(pos);
			if (pair && pair[1].getStartPosition().equals(pos)) {
				return Selection.fromPositions(pair[0].getEndPosition(), pair[1].getStartPosition());
			}
		}

		return undefined;
	}

	/**
	 * Selects content inside a string if the position is right after an opening quote or right before a closing quote.
	 * @param pos The position in the model.