<commit_before>/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
'use strict';

import * as nls from 'vs/nls';
import {KeyCode, KeyMod} from 'vs/base/common/keyCodes';
import {TPromise} from 'vs/base/common/winjs.base';
import {DefaultConfig} from 'vs/editor/common/config/defaultConfig';
import {EditorAction} from 'vs/editor/common/editorAction';
import {Behaviour} from 'vs/editor/common/editorActionEnablement';
import {ICommonCodeEditor, IEditorActionDescriptorData} from 'vs/editor/common/editorCommon';
import {CommonEditorRegistry, ContextKey, EditorActionDescriptor} from 'vs/editor/common/editorCommonExtensions';

class ToggleWordWrapAction extends EditorAction {

	static ID = 'editor.action.toggleWordWrap';

	constructor(descriptor:IEditorActionDescriptorData, editor:ICommonCodeEditor) {
		super(descriptor, editor, Behaviour.TextFocus);
	}

	public run():TPromise<boolean> {

		let wrappingInfo = this.editor.getConfiguration().wrappingInfo;

		if (!wrappingInfo.isViewportWrapping) {
			wrappingInfo.wrappingColumn = 0;
		} else {
			wrappingInfo.wrappingColumn = DefaultConfig.editor.wrappingColumn;
		}
		this.editor.updateOptions(wrappingInfo);

		return TPromise.as(true);
	}
}

// register actions
CommonEditorRegistry.registerEditorAction(new EditorActionDescriptor(ToggleWordWrapAction, ToggleWordWrapAction.ID, nls.localize('toggle.wordwrap', "View: Toggle Word Wrap"), {
	context: ContextKey.EditorTextFocus,
	primary: KeyMod.Alt | KeyCode.KEY_Z,
	mac: { primary: KeyMod.Alt |  KeyCode.KEY_Z },
	linux: { primary: KeyMod.Alt | KeyCode.KEY_Z }
}, 'View: Toggle Word Wrap'));<commit_msg>Fixes #4797: Toggle Word Wrap forces no wrapping<commit_after>/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
'use strict';

import * as nls from 'vs/nls';
import {KeyCode, KeyMod} from 'vs/base/common/keyCodes';
import {TPromise} from 'vs/base/common/winjs.base';
import {EditorAction} from 'vs/editor/common/editorAction';
import {Behaviour} from 'vs/editor/common/editorActionEnablement';
import {ICommonCodeEditor, IEditorActionDescriptorData} from 'vs/editor/common/editorCommon';
import {CommonEditorRegistry, ContextKey, EditorActionDescriptor} from 'vs/editor/common/editorCommonExtensions';

class ToggleWordWrapAction extends EditorAction {

	static ID = 'editor.action.toggleWordWrap';

	constructor(descriptor:IEditorActionDescriptorData, editor:ICommonCodeEditor) {
		super(descriptor, editor, Behaviour.TextFocus);
	}

	public run():TPromise<boolean> {

		let wrappingInfo = this.editor.getConfiguration().wrappingInfo;

		if (!wrappingInfo.isViewportWrapping) {
			wrappingInfo.wrappingColumn = 0;
		} else {
			wrappingInfo.wrappingColumn = -1;
		}
		this.editor.updateOptions(wrappingInfo);

		return TPromise.as(true);
	}
}

// register actions
CommonEditorRegistry.registerEditorAction(new EditorActionDescriptor(ToggleWordWrapAction, ToggleWordWrapAction.ID, nls.localize('toggle.wordwrap', "View: Toggle Word Wrap"), {
	context: ContextKey.EditorTextFocus,
	primary: KeyMod.Alt | KeyCode.KEY_Z,
	mac: { primary: KeyMod.Alt |  KeyCode.KEY_Z },
	linux: { primary: KeyMod.Alt | KeyCode.KEY_Z }
}, 'View: Toggle Word Wrap'));
{'fraction_non_alphanumeric': 0.20164937483373238, 'fraction_numerical': 0.00186219739292365, 'mean_word_length': 3.3873978996499416, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4739111', 'n_tokens_mistral': 1066, 'n_tokens_neox': 1049, 'n_words': 232}